diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5c77a38..f72394e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,14 +12,9 @@ jobs: lint: name: lint runs-on: ubuntu-latest - - steps: - uses: actions/checkout@v4 - - name: Validate Gradle wrapper - uses: gradle/actions/wrapper-validation@v3 - - name: Set up Java uses: actions/setup-java@v4 with: @@ -30,9 +25,7 @@ jobs: cache: gradle - name: Set up Gradle - uses: gradle/gradle-build-action@v2 + uses: gradle/actions/setup-gradle@v4 - name: Run lints run: ./scripts/lint - - diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml deleted file mode 100644 index 58107af0..00000000 --- a/.github/workflows/create-releases.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Create releases -on: - schedule: - - cron: '0 5 * * *' # every day at 5am UTC - push: - branches: - - main - -jobs: - release: - name: release - if: github.ref == 'refs/heads/main' && github.repository == 'openlayer-ai/openlayer-java' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - uses: stainless-api/trigger-release-please@v1 - id: release - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} - - - name: Set up Java - if: ${{ steps.release.outputs.releases_created }} - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: | - 8 - 17 - cache: gradle - - - name: Set up Gradle - if: ${{ steps.release.outputs.releases_created }} - uses: gradle/gradle-build-action@v2 - - - name: Publish to Sonatype - if: ${{ steps.release.outputs.releases_created }} - run: | - ./gradlew --parallel --no-daemon publish - env: - SONATYPE_USERNAME: ${{ secrets.OPENLAYER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.OPENLAYER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} - GPG_SIGNING_KEY_ID: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_KEY_ID || secrets.GPG_SIGNING_KEY_ID }} - GPG_SIGNING_KEY: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} - GPG_SIGNING_PASSWORD: ${{ secrets.OPENLAYER_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.github/workflows/handle-release-pr-title-edit.yml b/.github/workflows/handle-release-pr-title-edit.yml deleted file mode 100644 index ac2a6802..00000000 --- a/.github/workflows/handle-release-pr-title-edit.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Handle release PR title edits -on: - pull_request: - types: - - edited - - unlabeled - -jobs: - update_pr_content: - name: Update pull request content - if: | - ((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) || - (github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) && - startsWith(github.event.pull_request.head.ref, 'release-please--') && - github.event.pull_request.state == 'open' && - github.event.sender.login != 'stainless-bot' && - github.event.sender.login != 'stainless-app' && - github.repository == 'openlayer-ai/openlayer-java' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: stainless-api/trigger-release-please@v1 - with: - repo: ${{ github.event.repository.full_name }} - stainless-api-key: ${{ secrets.STAINLESS_API_KEY }} diff --git a/.gitignore b/.gitignore index 39c31e3e..4e81838d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .prism.log .gradle .idea +.kotlin build codegen.log kls_database.db diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ee49ac2d..fd0ccba9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.11" + ".": "0.1.0-alpha.12" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index dd473053..5fc516db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1,3 @@ -configured_endpoints: 14 +configured_endpoints: 15 +openapi_spec_hash: 9a0b363025305f6b086bcdfe43274830 +config_hash: 21fb9730d1cdc9e3fd38724c4774b894 diff --git a/CHANGELOG.md b/CHANGELOG.md index ab2c9931..f6b6d739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,97 @@ # Changelog +## 0.1.0-alpha.12 (2025-04-10) + +Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/openlayer-ai/openlayer-java/compare/v0.1.0-alpha.11...v0.1.0-alpha.12) + +### ⚠ BREAKING CHANGES + +* **client:** refactor exception structure and methods ([#93](https://github.com/openlayer-ai/openlayer-java/issues/93)) +* **client:** move classes into subpackages and shorten names ([#80](https://github.com/openlayer-ai/openlayer-java/issues/80)) + +### Features + +* **api:** add endpoint to retrieve commit by id ([#77](https://github.com/openlayer-ai/openlayer-java/issues/77)) ([5087297](https://github.com/openlayer-ai/openlayer-java/commit/50872978eab416d1395b8619b965e7135d2aef65)) +* **api:** api update ([cedc29f](https://github.com/openlayer-ai/openlayer-java/commit/cedc29f79a787b41f0474355d38e2ef94c044123)) +* **client:** add `close` method ([207ba78](https://github.com/openlayer-ai/openlayer-java/commit/207ba785d6409b4a6b5ede70f3944313cd625b6c)) +* **client:** add enum validation method ([0c69b0d](https://github.com/openlayer-ai/openlayer-java/commit/0c69b0d67f818d7511495b196978e1d9a6f6de7d)) +* **client:** expose request body setter and getter ([#106](https://github.com/openlayer-ai/openlayer-java/issues/106)) ([8725baa](https://github.com/openlayer-ai/openlayer-java/commit/8725baa3ddd8d7fe53c607cd9d2e7f14373b37df)) +* **client:** make datetime deserialization more lenient ([#105](https://github.com/openlayer-ai/openlayer-java/issues/105)) ([ac0fa47](https://github.com/openlayer-ai/openlayer-java/commit/ac0fa470239a5ad32e3d372354f63da231a98480)) +* **client:** make union deserialization more robust ([#104](https://github.com/openlayer-ai/openlayer-java/issues/104)) ([0c69b0d](https://github.com/openlayer-ai/openlayer-java/commit/0c69b0d67f818d7511495b196978e1d9a6f6de7d)) +* **client:** support a lower jackson version ([#99](https://github.com/openlayer-ai/openlayer-java/issues/99)) ([86e9363](https://github.com/openlayer-ai/openlayer-java/commit/86e936338872071e1dcc80f0549adcb21f8aa205)) +* **client:** support setting base URL via env var ([08e6ac1](https://github.com/openlayer-ai/openlayer-java/commit/08e6ac1c7327d8c832035b29242b10c8678f2543)) +* **client:** throw on incompatible jackson version ([86e9363](https://github.com/openlayer-ai/openlayer-java/commit/86e936338872071e1dcc80f0549adcb21f8aa205)) + + +### Bug Fixes + +* **client:** bump to better jackson version ([fc11f45](https://github.com/openlayer-ai/openlayer-java/commit/fc11f45df797c93281e670e35ecd00c6530d0af4)) +* **client:** don't call `validate()` during deserialization if we don't have to ([#101](https://github.com/openlayer-ai/openlayer-java/issues/101)) ([5ce9c06](https://github.com/openlayer-ai/openlayer-java/commit/5ce9c0686bbf66a4f0e3e2acad3356664671d287)) +* **client:** limit json deserialization coercion ([#102](https://github.com/openlayer-ai/openlayer-java/issues/102)) ([15fddc3](https://github.com/openlayer-ai/openlayer-java/commit/15fddc34beea081f9afb69dc87302b65c1e82340)) +* **client:** make some classes and constructors non-public ([882eb61](https://github.com/openlayer-ai/openlayer-java/commit/882eb61286bb52c15224a36677a934523ccb4fb3)) +* **client:** map deserialization bug ([17fc1d7](https://github.com/openlayer-ai/openlayer-java/commit/17fc1d796ea7b17d34c0b14374fff3420a14397e)) +* **client:** return `Optional<T>` instead of `Optional` ([#109](https://github.com/openlayer-ai/openlayer-java/issues/109)) ([c2c1501](https://github.com/openlayer-ai/openlayer-java/commit/c2c150161ea17067c68e3ce7c54deebdf2461c4a)) +* **client:** support kotlin 1.8 runtime ([#90](https://github.com/openlayer-ai/openlayer-java/issues/90)) ([f2b112b](https://github.com/openlayer-ai/openlayer-java/commit/f2b112b2f218ba39307aad1ed17c0d6114142d3a)) +* pluralize `list` response variables ([#103](https://github.com/openlayer-ai/openlayer-java/issues/103)) ([c1cde72](https://github.com/openlayer-ai/openlayer-java/commit/c1cde726f563abe38a5188647c6f05df01d034e8)) + + +### Performance Improvements + +* **client:** cached parsed type in `HttpResponseFor` ([#107](https://github.com/openlayer-ai/openlayer-java/issues/107)) ([3bd7a4c](https://github.com/openlayer-ai/openlayer-java/commit/3bd7a4cc174f22a5e2ef4510ee1576563ad608c2)) + + +### Chores + +* **client:** move classes into subpackages and shorten names ([#80](https://github.com/openlayer-ai/openlayer-java/issues/80)) ([6e35cbf](https://github.com/openlayer-ai/openlayer-java/commit/6e35cbf67eab70e90be376b4835a9b000f265cf9)) +* **client:** refactor exception structure and methods ([#93](https://github.com/openlayer-ai/openlayer-java/issues/93)) ([d1ee889](https://github.com/openlayer-ai/openlayer-java/commit/d1ee889f1b5a4b8e97fff690f0c4db997441278f)) +* **client:** remove unnecessary json state from some query param classes ([0c69b0d](https://github.com/openlayer-ai/openlayer-java/commit/0c69b0d67f818d7511495b196978e1d9a6f6de7d)) +* **internal:** add invalid json deserialization tests ([0c69b0d](https://github.com/openlayer-ai/openlayer-java/commit/0c69b0d67f818d7511495b196978e1d9a6f6de7d)) +* **internal:** add json roundtripping tests ([0c69b0d](https://github.com/openlayer-ai/openlayer-java/commit/0c69b0d67f818d7511495b196978e1d9a6f6de7d)) +* **internal:** add missing release please block ([#92](https://github.com/openlayer-ai/openlayer-java/issues/92)) ([722165b](https://github.com/openlayer-ai/openlayer-java/commit/722165bcfa13936fc3ed70592833293495f1ed20)) +* **internal:** codegen related update ([c23eea2](https://github.com/openlayer-ai/openlayer-java/commit/c23eea21cd8a3895c7ed616998516df64ac1b9dd)) +* **internal:** codegen related update ([2885a5a](https://github.com/openlayer-ai/openlayer-java/commit/2885a5a402fa4cea4e5363a5dbec1bd255a9060b)) +* **internal:** codegen related update ([a62fb1f](https://github.com/openlayer-ai/openlayer-java/commit/a62fb1f2042721f6ce4eb84ff33bfd9704829266)) +* **internal:** codegen related update ([ca04676](https://github.com/openlayer-ai/openlayer-java/commit/ca0467688568fe952dc57739c6306209f68761f8)) +* **internal:** codegen related update ([#79](https://github.com/openlayer-ai/openlayer-java/issues/79)) ([3ee21d4](https://github.com/openlayer-ai/openlayer-java/commit/3ee21d4a05dddebac33326fd9c0cbde11bf39062)) +* **internal:** codegen related update ([#85](https://github.com/openlayer-ai/openlayer-java/issues/85)) ([3d4d199](https://github.com/openlayer-ai/openlayer-java/commit/3d4d19974440297e5b1f4fdd220ae2c29adfad00)) +* **internal:** delete duplicate tests ([ece3d6d](https://github.com/openlayer-ai/openlayer-java/commit/ece3d6d3f438671e2b4fab916f9295c668d2f137)) +* **internal:** delete unused methods and annotations ([#100](https://github.com/openlayer-ai/openlayer-java/issues/100)) ([17fc1d7](https://github.com/openlayer-ai/openlayer-java/commit/17fc1d796ea7b17d34c0b14374fff3420a14397e)) +* **internal:** expand CI branch coverage ([273f4a7](https://github.com/openlayer-ai/openlayer-java/commit/273f4a712c63235e663b5e2ddba53797f2cf441c)) +* **internal:** fix example formatting ([#95](https://github.com/openlayer-ai/openlayer-java/issues/95)) ([5c782e5](https://github.com/openlayer-ai/openlayer-java/commit/5c782e5d75daafb3eea58bbe5c834a3cf3444783)) +* **internal:** generate more tests ([db068dc](https://github.com/openlayer-ai/openlayer-java/commit/db068dc6e79b6a3fa77fe7b22a9a7bf31b61b8d9)) +* **internal:** make multipart assertions more robust ([ac5dc3b](https://github.com/openlayer-ai/openlayer-java/commit/ac5dc3bb775247428b484019d4f5a936877dac0e)) +* **internal:** reduce CI branch coverage ([3169980](https://github.com/openlayer-ai/openlayer-java/commit/3169980b67081c80cadb5af4869982a2a3eadedd)) +* **internal:** refactor `ErrorHandlingTest` ([2fca9f1](https://github.com/openlayer-ai/openlayer-java/commit/2fca9f1dbdc492be75166cc9727660dffd325ce8)) +* **internal:** refactor enum query param serialization ([#91](https://github.com/openlayer-ai/openlayer-java/issues/91)) ([b928602](https://github.com/openlayer-ai/openlayer-java/commit/b92860288151baab73f6ad26ffbd0976a3f54aab)) +* **internal:** refactor query param serialization impl and tests ([#87](https://github.com/openlayer-ai/openlayer-java/issues/87)) ([301bc32](https://github.com/openlayer-ai/openlayer-java/commit/301bc32db49ad7d0b417b98996f11ed445c2501c)) +* **internal:** refactor some test assertions ([ece3d6d](https://github.com/openlayer-ai/openlayer-java/commit/ece3d6d3f438671e2b4fab916f9295c668d2f137)) +* **internal:** reformat some tests ([#89](https://github.com/openlayer-ai/openlayer-java/issues/89)) ([db068dc](https://github.com/openlayer-ai/openlayer-java/commit/db068dc6e79b6a3fa77fe7b22a9a7bf31b61b8d9)) +* **internal:** remove extra empty newlines ([#81](https://github.com/openlayer-ai/openlayer-java/issues/81)) ([9eba32c](https://github.com/openlayer-ai/openlayer-java/commit/9eba32cbaa34b9c97ac7efd81533066229470ea5)) +* **internal:** remove some unnecessary `constructor` keywords ([882eb61](https://github.com/openlayer-ai/openlayer-java/commit/882eb61286bb52c15224a36677a934523ccb4fb3)) +* **internal:** remove unnecessary `assertNotNull` calls ([ac5dc3b](https://github.com/openlayer-ai/openlayer-java/commit/ac5dc3bb775247428b484019d4f5a936877dac0e)) +* **internal:** remove unnecessary import ([#96](https://github.com/openlayer-ai/openlayer-java/issues/96)) ([4852f0f](https://github.com/openlayer-ai/openlayer-java/commit/4852f0fc5face081a9d899a940ac15ee771df2e4)) +* **internal:** remove workflow ([54e8c73](https://github.com/openlayer-ai/openlayer-java/commit/54e8c738a650f838cdc25c71ad355c17b6b23867)) +* **internal:** rename `getPathParam` ([#88](https://github.com/openlayer-ai/openlayer-java/issues/88)) ([ece3d6d](https://github.com/openlayer-ai/openlayer-java/commit/ece3d6d3f438671e2b4fab916f9295c668d2f137)) +* **internal:** reorder some params methodsc ([ece3d6d](https://github.com/openlayer-ai/openlayer-java/commit/ece3d6d3f438671e2b4fab916f9295c668d2f137)) +* **internal:** swap from `getNullable` to `getOptional` ([#108](https://github.com/openlayer-ai/openlayer-java/issues/108)) ([3975381](https://github.com/openlayer-ai/openlayer-java/commit/3975381f2e6a9183a11200ca5a2e1ff5a260e784)) +* **internal:** version bump ([4937ab9](https://github.com/openlayer-ai/openlayer-java/commit/4937ab9a3d67bdb756b8632dd934d4330e3b6f5a)) +* **tests:** improve enum examples ([#111](https://github.com/openlayer-ai/openlayer-java/issues/111)) ([b8c855b](https://github.com/openlayer-ai/openlayer-java/commit/b8c855b09d13118ca76e7c053f5a1c76f33c4640)) + + +### Documentation + +* `async` and `sync` method comments ([0083c41](https://github.com/openlayer-ai/openlayer-java/commit/0083c41a6cc82a368e64ec0a812935597fa330e5)) +* add `build` method comments ([#86](https://github.com/openlayer-ai/openlayer-java/issues/86)) ([e6da0bf](https://github.com/openlayer-ai/openlayer-java/commit/e6da0bfc278f0405e7a875e53574abff11033bea)) +* add client documentation ([ad4f217](https://github.com/openlayer-ai/openlayer-java/commit/ad4f217728a1fc01dacc4587004a086350f4ccc4)) +* add comments to `JsonField` classes ([c2c1501](https://github.com/openlayer-ai/openlayer-java/commit/c2c150161ea17067c68e3ce7c54deebdf2461c4a)) +* builder, enum, and union comments ([5f394f5](https://github.com/openlayer-ai/openlayer-java/commit/5f394f52f0d57b38f9664f135e58fa89f98a19d5)) +* deduplicate and refine comments ([#84](https://github.com/openlayer-ai/openlayer-java/issues/84)) ([687dd63](https://github.com/openlayer-ai/openlayer-java/commit/687dd630eed0499e0b786c0df214c8671ae43402)) +* document how to forcibly omit required field ([f7bf9f7](https://github.com/openlayer-ai/openlayer-java/commit/f7bf9f790253baaf2b8f9a192eac238db160e62b)) +* minor readme tweak ([#98](https://github.com/openlayer-ai/openlayer-java/issues/98)) ([dd9ea15](https://github.com/openlayer-ai/openlayer-java/commit/dd9ea155bb0a7f67ab500de13ee44def664d253e)) +* refine comments on multipart params ([#94](https://github.com/openlayer-ai/openlayer-java/issues/94)) ([ac5dc3b](https://github.com/openlayer-ai/openlayer-java/commit/ac5dc3bb775247428b484019d4f5a936877dac0e)) +* swap examples used in readme ([#110](https://github.com/openlayer-ai/openlayer-java/issues/110)) ([f7bf9f7](https://github.com/openlayer-ai/openlayer-java/commit/f7bf9f790253baaf2b8f9a192eac238db160e62b)) +* update readme exception docs ([#97](https://github.com/openlayer-ai/openlayer-java/issues/97)) ([7eafb98](https://github.com/openlayer-ai/openlayer-java/commit/7eafb987ad975163a4bda700271c3c752f6b4430)) + ## 0.1.0-alpha.11 (2024-12-20) Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/openlayer-ai/openlayer-java/compare/v0.1.0-alpha.10...v0.1.0-alpha.11) diff --git a/LICENSE b/LICENSE index 82530825..ac864c56 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2024 Openlayer + Copyright 2025 Openlayer Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index ed0596e7..aab9176b 100644 --- a/README.md +++ b/README.md @@ -2,203 +2,310 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.1.0-alpha.11) +[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.1.0-alpha.12) +[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.1.0-alpha.12/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.1.0-alpha.12) -The Openlayer Java SDK provides convenient access to the Openlayer REST API from applications written in Java. It includes helper classes with helpful types and documentation for every request and response property. +The Openlayer Java SDK provides convenient access to the [Openlayer REST API](https://openlayer.com/docs/api-reference/rest/overview) from applications written in Java. -The Openlayer Java SDK is similar to the Openlayer Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as `Optional` instead of nullable values, `Stream` instead of `Sequence`, and `CompletableFuture` instead of suspend functions. +It is generated with [Stainless](https://www.stainless.com/). -It is generated with [Stainless](https://www.stainlessapi.com/). - -## Documentation - -The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). - ---- + -## Getting started +The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.1.0-alpha.12). -### Install dependencies + -#### Gradle +## Installation +### Gradle + ```kotlin -implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.11") +implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.12") ``` -#### Maven +### Maven ```xml - com.openlayer.api - openlayer-java - 0.1.0-alpha.11 + com.openlayer.api + openlayer-java + 0.1.0-alpha.12 ``` -### Configure the client +## Requirements -Use `OpenlayerOkHttpClient.builder()` to configure the client. +This library requires Java 8 or later. -Alternately, set the environment with `OPENLAYER_API_KEY`, and use `OpenlayerOkHttpClient.fromEnv()` to read from the environment. +## Usage ```java import com.openlayer.api.client.OpenlayerClient; import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient; +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; +// Configures using the `OPENLAYER_API_KEY` and `OPENLAYER_BASE_URL` environment variables OpenlayerClient client = OpenlayerOkHttpClient.fromEnv(); -// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties +DataStreamParams params = DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config(DataStreamParams.Config.LlmData.builder() + .addInputVariableName("user_query") + .outputColumnName("output") + .numOfTokenColumnName("tokens") + .costColumnName("cost") + .timestampColumnName("timestamp") + .build()) + .addRow(DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("what is the meaning of life?")) + .putAdditionalProperty("output", JsonValue.from("42")) + .putAdditionalProperty("tokens", JsonValue.from(7)) + .putAdditionalProperty("cost", JsonValue.from(0.02)) + .putAdditionalProperty("timestamp", JsonValue.from(1610000000)) + .build()) + .build(); +DataStreamResponse response = client.inferencePipelines().data().stream(params); +``` + +## Client configuration + +Configure the client using environment variables: + +```java +import com.openlayer.api.client.OpenlayerClient; +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient; + +// Configures using the `OPENLAYER_API_KEY` and `OPENLAYER_BASE_URL` environment variables +OpenlayerClient client = OpenlayerOkHttpClient.fromEnv(); +``` + +Or manually: + +```java +import com.openlayer.api.client.OpenlayerClient; +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient; + +OpenlayerClient client = OpenlayerOkHttpClient.builder() + .apiKey("My API Key") + .build(); +``` + +Or using a combination of the two approaches: + +```java +import com.openlayer.api.client.OpenlayerClient; +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient; + OpenlayerClient client = OpenlayerOkHttpClient.builder() + // Configures using the `OPENLAYER_API_KEY` and `OPENLAYER_BASE_URL` environment variables .fromEnv() - // ... set properties on the builder + .apiKey("My API Key") .build(); ``` -| Property | Environment variable | Required | Default value | -| -------- | -------------------- | -------- | ------------- | -| apiKey | `OPENLAYER_API_KEY` | false | — | +See this table for the available options: + +| Setter | Environment variable | Required | Default value | +| --------- | -------------------- | -------- | -------------------------------- | +| `apiKey` | `OPENLAYER_API_KEY` | false | - | +| `baseUrl` | `OPENLAYER_BASE_URL` | true | `"https://api.openlayer.com/v1"` | + +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. -Read the documentation for more configuration options. +## Requests and responses ---- +To send a request to the Openlayer API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -### Example: creating a resource +For example, `client.inferencePipelines().data().stream(...)` should be called with an instance of `DataStreamParams`, and it will return an instance of `DataStreamResponse`. -To create a new inference pipeline data, first use the `InferencePipelineDataStreamParams` builder to specify attributes, then pass that to the `stream` method of the `data` service. +## Immutability + +Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it. + +Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy. + +Because each class is immutable, builder modification will _never_ affect already built class instances. + +## Asynchronous execution + +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: ```java +import com.openlayer.api.client.OpenlayerClient; +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient; import com.openlayer.api.core.JsonValue; -import com.openlayer.api.models.InferencePipelineDataStreamParams; -import com.openlayer.api.models.InferencePipelineDataStreamResponse; -import java.util.List; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; +import java.util.concurrent.CompletableFuture; + +// Configures using the `OPENLAYER_API_KEY` and `OPENLAYER_BASE_URL` environment variables +OpenlayerClient client = OpenlayerOkHttpClient.fromEnv(); -InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.builder() +DataStreamParams params = DataStreamParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config(InferencePipelineDataStreamParams.Config.ofLlmData(InferencePipelineDataStreamParams.Config.LlmData.builder() - .inputVariableNames(List.of("user_query")) + .config(DataStreamParams.Config.LlmData.builder() + .addInputVariableName("user_query") .outputColumnName("output") .numOfTokenColumnName("tokens") .costColumnName("cost") .timestampColumnName("timestamp") - .build())) - .rows(List.of(InferencePipelineDataStreamParams.Row.builder() + .build()) + .addRow(DataStreamParams.Row.builder() .putAdditionalProperty("user_query", JsonValue.from("what is the meaning of life?")) .putAdditionalProperty("output", JsonValue.from("42")) .putAdditionalProperty("tokens", JsonValue.from(7)) .putAdditionalProperty("cost", JsonValue.from(0.02)) .putAdditionalProperty("timestamp", JsonValue.from(1610000000)) - .build())) + .build()) .build(); -InferencePipelineDataStreamResponse response = client.inferencePipelines().data().stream(params); +CompletableFuture response = client.async().inferencePipelines().data().stream(params); ``` ---- +Or create an asynchronous client from the beginning: + +```java +import com.openlayer.api.client.OpenlayerClientAsync; +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync; +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; +import java.util.concurrent.CompletableFuture; -## Requests +// Configures using the `OPENLAYER_API_KEY` and `OPENLAYER_BASE_URL` environment variables +OpenlayerClientAsync client = OpenlayerOkHttpClientAsync.fromEnv(); + +DataStreamParams params = DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config(DataStreamParams.Config.LlmData.builder() + .addInputVariableName("user_query") + .outputColumnName("output") + .numOfTokenColumnName("tokens") + .costColumnName("cost") + .timestampColumnName("timestamp") + .build()) + .addRow(DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("what is the meaning of life?")) + .putAdditionalProperty("output", JsonValue.from("42")) + .putAdditionalProperty("tokens", JsonValue.from(7)) + .putAdditionalProperty("cost", JsonValue.from(0.02)) + .putAdditionalProperty("timestamp", JsonValue.from(1610000000)) + .build()) + .build(); +CompletableFuture response = client.inferencePipelines().data().stream(params); +``` -### Parameters and bodies +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. -To make a request to the Openlayer API, you generally build an instance of the appropriate `Params` class. +## Raw responses -In [Example: creating a resource](#example-creating-a-resource) above, we used the `InferencePipelineDataStreamParams.builder()` to pass to the `stream` method of the `data` service. +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. -Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method. +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java import com.openlayer.api.core.JsonValue; -import com.openlayer.api.models.InferencePipelineDataStreamParams; +import com.openlayer.api.core.http.Headers; +import com.openlayer.api.core.http.HttpResponseFor; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; -InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.builder() - // ... normal properties - .putAdditionalProperty("secret_param", JsonValue.from("4242")) +DataStreamParams params = DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config(DataStreamParams.Config.LlmData.builder() + .addInputVariableName("user_query") + .outputColumnName("output") + .numOfTokenColumnName("tokens") + .costColumnName("cost") + .timestampColumnName("timestamp") + .build()) + .addRow(DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("what is the meaning of life?")) + .putAdditionalProperty("output", JsonValue.from("42")) + .putAdditionalProperty("tokens", JsonValue.from(7)) + .putAdditionalProperty("cost", JsonValue.from(0.02)) + .putAdditionalProperty("timestamp", JsonValue.from(1610000000)) + .build()) .build(); -``` - -## Responses +HttpResponseFor response = client.inferencePipelines().data().withRawResponse().stream(params); -### Response validation +int statusCode = response.statusCode(); +Headers headers = response.headers(); +``` -When receiving a response, the Openlayer Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OpenlayerInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model. +You can still deserialize the response into an instance of a Java class if needed: ```java -import com.openlayer.api.models.InferencePipelineDataStreamResponse; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; -InferencePipelineDataStreamResponse response = client.inferencePipelines().data().stream().validate(); +DataStreamResponse parsedResponse = response.parse(); ``` -### Response properties as JSON - -In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value. +## Error handling -```java -import com.openlayer.api.core.JsonField; -import java.util.Optional; +The SDK throws custom unchecked exception types: -JsonField field = responseObj._field(); +- [`OpenlayerServiceException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: -if (field.isMissing()) { - // Value was not specified in the JSON response -} else if (field.isNull()) { - // Value was provided as a literal null -} else { - // See if value was provided as a string - Optional jsonString = field.asString(); + | Status | Exception | + | ------ | -------------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt) | - // If the value given by the API did not match the shape that the SDK expects - // you can deserialise into a custom type - MyClass myObj = responseObj._field().asUnknown().orElseThrow().convert(MyClass.class); -} -``` +- [`OpenlayerIoException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerIoException.kt): I/O networking errors. -### Additional model properties +- [`OpenlayerInvalidDataException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. -Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method: +- [`OpenlayerException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. -```java -import com.openlayer.api.core.JsonValue; +## Logging -JsonValue secret = projectCreateResponse._additionalProperties().get("secret_field"); -``` +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). ---- +Enable logging by setting the `OPENLAYER_LOG` environment variable to `info`: ---- +```sh +$ export OPENLAYER_LOG=info +``` -## Error handling +Or to `debug` for more verbose logging: -This library throws exceptions in a single hierarchy for easy handling: +```sh +$ export OPENLAYER_LOG=debug +``` -- **`OpenlayerException`** - Base exception for all exceptions +## Network options -- **`OpenlayerServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server. +### Retries - | 400 | BadRequestException | - | ------ | ----------------------------- | - | 401 | AuthenticationException | - | 403 | PermissionDeniedException | - | 404 | NotFoundException | - | 422 | UnprocessableEntityException | - | 429 | RateLimitException | - | 5xx | InternalServerException | - | others | UnexpectedStatusCodeException | +The SDK automatically retries 2 times by default, with a short exponential backoff. -- **`OpenlayerIoException`** - I/O networking errors -- **`OpenlayerInvalidDataException`** - any other exceptions on the client side, e.g.: - - We failed to serialize the request body - - We failed to parse the response body (has access to response code and body) +Only the following error types are retried: -## Network options +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal -### Retries +The API may also explicitly instruct the SDK to retry or not retry a response. -Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this: +To set a custom number of retries, configure the client using the `maxRetries` method: ```java import com.openlayer.api.client.OpenlayerClient; @@ -212,7 +319,21 @@ OpenlayerClient client = OpenlayerOkHttpClient.builder() ### Timeouts -Requests time out after 1 minute by default. You can configure this on the client builder: +Requests time out after 1 minute by default. + +To set a custom timeout, configure the method call using the `timeout` method: + +```java +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; + +DataStreamResponse response = client.inferencePipelines().data().stream( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); +``` + +Or configure the default for all method calls at the client level: ```java import com.openlayer.api.client.OpenlayerClient; @@ -227,7 +348,7 @@ OpenlayerClient client = OpenlayerOkHttpClient.builder() ### Proxies -Requests can be routed through a proxy. You can configure this on the client builder: +To route requests through a proxy, configure the client using the `proxy` method: ```java import com.openlayer.api.client.OpenlayerClient; @@ -237,56 +358,261 @@ import java.net.Proxy; OpenlayerClient client = OpenlayerOkHttpClient.builder() .fromEnv() - .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("example.com", 8080))) + .proxy(new Proxy( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) .build(); ``` -## Making custom/undocumented requests +## Undocumented API functionality -This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used. +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. -### Undocumented request params +### Parameters -To make requests using undocumented parameters, you can provide or override parameters on the params object while building it. +To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: -```kotlin -FooCreateParams address = FooCreateParams.builder() - .id("my_id") - .putAdditionalProperty("secret_prop", JsonValue.from("hello")) +```java +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; + +DataStreamParams params = DataStreamParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build(); ``` -### Undocumented response properties +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. -To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map`. You can then access fields like `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type. +To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: -## Logging +```java +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.projects.ProjectCreateParams; -We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). +ProjectCreateParams params = ProjectCreateParams.builder() + .links(ProjectCreateParams.Links.builder() + .putAdditionalProperty("secretProperty", JsonValue.from("42")) + .build()) + .build(); +``` -You can enable logging by setting the environment variable `OPENLAYER_LOG` to `info`. +These properties can be accessed on the nested built object later using the `_additionalProperties()` method. -```sh -$ export OPENLAYER_LOG=info +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt) object to its setter: + +```java +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; + +DataStreamParams params = DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config(DataStreamParams.Config.LlmData.builder() + .addInputVariableName("user_query") + .outputColumnName("output") + .numOfTokenColumnName("tokens") + .costColumnName("cost") + .timestampColumnName("timestamp") + .build()) + .rows(JsonValue.from(42)) + .build(); ``` -Or to `debug` for more verbose logging. +The most straightforward way to create a [`JsonValue`](openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt) is using its `from(...)` method: -```sh -$ export OPENLAYER_LOG=debug +```java +import com.openlayer.api.core.JsonValue; +import java.util.List; +import java.util.Map; + +// Create primitive JSON values +JsonValue nullValue = JsonValue.from(null); +JsonValue booleanValue = JsonValue.from(true); +JsonValue numberValue = JsonValue.from(42); +JsonValue stringValue = JsonValue.from("Hello World!"); + +// Create a JSON array value equivalent to `["Hello", "World"]` +JsonValue arrayValue = JsonValue.from(List.of( + "Hello", "World" +)); + +// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` +JsonValue objectValue = JsonValue.from(Map.of( + "a", 1, + "b", 2 +)); + +// Create an arbitrarily nested JSON equivalent to: +// { +// "a": [1, 2], +// "b": [3, 4] +// } +JsonValue complexValue = JsonValue.from(Map.of( + "a", List.of( + 1, 2 + ), + "b", List.of( + 3, 4 + ) +)); +``` + +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. + +To forcibly omit a required parameter or property, pass [`JsonMissing`](openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt): + +```java +import com.openlayer.api.core.JsonMissing; +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; + +DataStreamParams params = DataStreamParams.builder() + .config(DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .build()) + .addRow(DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build()) + .inferencePipelineId(JsonMissing.of()) + .build(); +``` + +### Response properties + +To access undocumented response properties, call the `_additionalProperties()` method: + +```java +import com.openlayer.api.core.JsonValue; +import java.util.Map; + +Map additionalProperties = client.inferencePipelines().data().stream(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); + +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } + + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } + + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } + + // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject` + // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden +}); ``` +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: + +```java +import com.openlayer.api.core.JsonField; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import java.util.Optional; + +JsonField config = client.inferencePipelines().data().stream(params)._config(); + +if (config.isMissing()) { + // The property is absent from the JSON response +} else if (config.isNull()) { + // The property was set to literal null +} else { + // Check if value was provided as a string + // Other methods include `asNumber()`, `asBoolean()`, etc. + Optional jsonString = config.asString(); + + // Try to deserialize into a custom type + MyClass myObject = config.asUnknown().orElseThrow().convert(MyClass.class); +} +``` + +### Response validation + +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. + +By default, the SDK will not throw an exception in this case. It will throw [`OpenlayerInvalidDataException`](openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerInvalidDataException.kt) only if you directly access the property. + +If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: + +```java +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; + +DataStreamResponse response = client.inferencePipelines().data().stream(params).validate(); +``` + +Or configure the method call to validate the response using the `responseValidation` method: + +```java +import com.openlayer.api.core.JsonValue; +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams; +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse; + +DataStreamResponse response = client.inferencePipelines().data().stream( + params, RequestOptions.builder().responseValidation(true).build() +); +``` + +Or configure the default for all method calls at the client level: + +```java +import com.openlayer.api.client.OpenlayerClient; +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient; + +OpenlayerClient client = OpenlayerOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); +``` + +## FAQ + +### Why don't you use plain `enum` classes? + +Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value. + +### Why do you represent fields using `JsonField` instead of just plain `T`? + +Using `JsonField` enables a few features: + +- Allowing usage of [undocumented API functionality](#undocumented-api-functionality) +- Lazily [validating the API response against the expected shape](#response-validation) +- Representing absent vs explicitly null values + +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? + +It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class. + +### Why don't you use checked exceptions? + +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: + +- Are verbose to handle +- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error +- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function) +- Don't play well with lambdas (also due to the function coloring problem) + ## Semantic versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_. +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ 2. Changes that we do not expect to impact the vast majority of users in practice. 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/openlayer-ai/openlayer-java/issues) with questions, bugs, or suggestions. - -## Requirements - -This library requires Java 8 or later. diff --git a/SECURITY.md b/SECURITY.md index 6dfa13e4..8614b059 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Reporting Security Issues -This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. -To report a security issue, please contact the Stainless team at security@stainlessapi.com. +To report a security issue, please contact the Stainless team at security@stainless.com. ## Responsible Disclosure diff --git a/build.gradle.kts b/build.gradle.kts index 6466dce7..e74d61c0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,23 @@ plugins { + id("org.jetbrains.dokka") version "2.0.0" +} +repositories { + mavenCentral() } allprojects { group = "com.openlayer.api" - version = "0.1.0-alpha.11" // x-release-please-version + version = "0.1.0-alpha.12" // x-release-please-version } +subprojects { + apply(plugin = "org.jetbrains.dokka") +} +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "openlayer-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 493cb327..778c89de 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,6 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "1.9.22" + kotlin("jvm") version "1.9.20" id("com.vanniktech.maven.publish") version "0.28.0" } @@ -10,7 +10,7 @@ repositories { } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") + implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0") } diff --git a/buildSrc/src/main/kotlin/openlayer.java.gradle.kts b/buildSrc/src/main/kotlin/openlayer.java.gradle.kts index 32a150ed..e39d9ac6 100644 --- a/buildSrc/src/main/kotlin/openlayer.java.gradle.kts +++ b/buildSrc/src/main/kotlin/openlayer.java.gradle.kts @@ -1,9 +1,5 @@ import com.diffplug.gradle.spotless.SpotlessExtension import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import com.vanniktech.maven.publish.JavaLibrary -import com.vanniktech.maven.publish.JavadocJar -import com.vanniktech.maven.publish.MavenPublishBaseExtension -import com.vanniktech.maven.publish.SonatypeHost plugins { `java-library` @@ -27,6 +23,9 @@ java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } tasks.withType().configureEach { @@ -43,9 +42,13 @@ tasks.named("jar") { } } -tasks.named("test") { +tasks.withType().configureEach { useJUnitPlatform() + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + testLogging { exceptionFormat = TestExceptionFormat.FULL } diff --git a/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts b/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts index b0bd08ab..f8d2c677 100644 --- a/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts @@ -1,6 +1,6 @@ import com.diffplug.gradle.spotless.SpotlessExtension -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import com.vanniktech.maven.publish.* +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion plugins { id("openlayer.java") @@ -11,6 +11,20 @@ kotlin { jvmToolchain { languageVersion.set(JavaLanguageVersion.of(17)) } + + compilerOptions { + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. + "-nowarn", + ) + jvmTarget.set(JvmTarget.JVM_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_8) + coreLibrariesVersion = "1.8.0" + } } configure { @@ -20,10 +34,8 @@ configure { } } -tasks.withType().configureEach { - kotlinOptions { - allWarningsAsErrors = true - freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8") - jvmTarget = "1.8" - } +// Run tests in parallel to some degree. +tasks.withType().configureEach { + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 } diff --git a/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts b/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts index d159a4fa..5f23d62a 100644 --- a/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts @@ -1,10 +1,5 @@ -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.get -import com.vanniktech.maven.publish.JavaLibrary import com.vanniktech.maven.publish.JavadocJar +import com.vanniktech.maven.publish.KotlinJvm import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost @@ -25,7 +20,13 @@ configure { signAllPublications() publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - this.coordinates(project.group.toString(), project.name, project.version.toString()) + coordinates(project.group.toString(), project.name, project.version.toString()) + configure( + KotlinJvm( + javadocJar = JavadocJar.Dokka("dokkaJavadoc"), + sourcesJar = true, + ) + ) pom { name.set("Openlayer API") diff --git a/gradle.properties b/gradle.properties index a3bc58f2..0c8d4ded 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,5 @@ org.gradle.caching=true -org.gradle.jvmargs=-Xmx4g org.gradle.parallel=true +org.gradle.daemon=false +org.gradle.jvmargs=-Xmx4g kotlin.daemon.jvmargs=-Xmx4g diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136..a4b76b95 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..cea7a793 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 25da30db..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## diff --git a/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OkHttpClient.kt b/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OkHttpClient.kt index cd4ff7dc..83f7a9cf 100644 --- a/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OkHttpClient.kt +++ b/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OkHttpClient.kt @@ -1,6 +1,8 @@ package com.openlayer.api.client.okhttp import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.Timeout +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.HttpClient import com.openlayer.api.core.http.HttpMethod @@ -30,38 +32,8 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : HttpClient { - private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { - val clientBuilder = okHttpClient.newBuilder() - - val logLevel = - when (System.getenv("OPENLAYER_LOG")?.lowercase()) { - "info" -> HttpLoggingInterceptor.Level.BASIC - "debug" -> HttpLoggingInterceptor.Level.BODY - else -> null - } - if (logLevel != null) { - clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } - ) - } - - val timeout = requestOptions.timeout - if (timeout != null) { - clientBuilder - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) - } - - return clientBuilder.build() - } - - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { - val call = getClient(requestOptions).newCall(request.toRequest()) + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val call = newCall(request, requestOptions) return try { call.execute().toResponse() @@ -80,18 +52,18 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val request.body?.run { future.whenComplete { _, _ -> close() } } - val call = getClient(requestOptions).newCall(request.toRequest()) - call.enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(OpenlayerIoException("Request failed", e)) + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(OpenlayerIoException("Request failed", e)) + } } - } - ) + ) return future } @@ -102,10 +74,36 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val okHttpClient.cache?.close() } - private fun HttpRequest.toRequest(): Request { + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("OPENLAYER_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) + } + + requestOptions.timeout?.let { + clientBuilder + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { var body: RequestBody? = body?.toRequestBody() - // OkHttpClient always requires a request body for PUT and POST methods. - if (body == null && (method == HttpMethod.PUT || method == HttpMethod.POST)) { + if (body == null && requiresBody(method)) { body = "".toRequestBody() } @@ -114,9 +112,33 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val headers.values(name).forEach { builder.header(name, it) } } + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + return builder.build() } + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + private fun HttpRequest.toUrl(): String { url?.let { return it @@ -170,29 +192,30 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var baseUrl: HttpUrl? = null - // The default timeout is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() - .connectTimeout(timeout) - .readTimeout(timeout) - .writeTimeout(timeout) - .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) .proxy(proxy) .build(), - checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + checkRequired("baseUrl", baseUrl), ) } } diff --git a/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClient.kt b/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClient.kt index 6369d219..84b59f0f 100644 --- a/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClient.kt +++ b/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClient.kt @@ -6,32 +6,43 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.openlayer.api.client.OpenlayerClient import com.openlayer.api.client.OpenlayerClientImpl import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.Timeout import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class OpenlayerOkHttpClient private constructor() { companion object { + /** Returns a mutable builder for constructing an instance of [OpenlayerOkHttpClient]. */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OpenlayerClient = builder().fromEnv().build() } - class Builder { + /** A builder for [OpenlayerOkHttpClient]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } @@ -118,7 +129,19 @@ class OpenlayerOkHttpClient private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } @@ -130,14 +153,22 @@ class OpenlayerOkHttpClient private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [OpenlayerClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OpenlayerClient = OpenlayerClientImpl( clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClientAsync.kt b/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClientAsync.kt index 3bd8ace4..ed7c1612 100644 --- a/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClientAsync.kt +++ b/openlayer-java-client-okhttp/src/main/kotlin/com/openlayer/api/client/okhttp/OpenlayerOkHttpClientAsync.kt @@ -6,32 +6,45 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.openlayer.api.client.OpenlayerClientAsync import com.openlayer.api.client.OpenlayerClientAsyncImpl import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.Timeout import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import java.net.Proxy import java.time.Clock import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class OpenlayerOkHttpClientAsync private constructor() { companion object { + /** + * Returns a mutable builder for constructing an instance of [OpenlayerOkHttpClientAsync]. + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): OpenlayerClientAsync = builder().fromEnv().build() } - class Builder { + /** A builder for [OpenlayerOkHttpClientAsync]. */ + class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL - // The default timeout for the client is 1 minute. - private var timeout: Duration = Duration.ofSeconds(60) + private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) } fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } @@ -118,7 +131,19 @@ class OpenlayerOkHttpClientAsync private constructor() { clientOptions.removeAllQueryParams(keys) } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { + clientOptions.timeout(timeout) + this.timeout = timeout + } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } @@ -130,14 +155,22 @@ class OpenlayerOkHttpClientAsync private constructor() { fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + fun fromEnv() = apply { clientOptions.fromEnv() } + /** + * Returns an immutable instance of [OpenlayerClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): OpenlayerClientAsync = OpenlayerClientAsyncImpl( clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/openlayer-java-core/build.gradle.kts b/openlayer-java-core/build.gradle.kts index cbb56c6f..5e14f894 100644 --- a/openlayer-java-core/build.gradle.kts +++ b/openlayer-java-core/build.gradle.kts @@ -3,14 +3,28 @@ plugins { id("openlayer.publish") } +configurations.all { + resolutionStrategy { + // Compile and test against a lower Jackson version to ensure we're compatible with it. + // We publish with a higher version (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.13.4") + force("com.fasterxml.jackson.core:jackson-databind:2.13.4") + force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + } +} + dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.18.1") - api("com.fasterxml.jackson.core:jackson-databind:2.18.1") + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") + api("com.google.errorprone:error_prone_annotations:2.33.0") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") @@ -20,6 +34,7 @@ dependencies { testImplementation("org.assertj:assertj-core:3.25.3") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") testImplementation("org.mockito:mockito-core:5.14.2") testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt index b7d18d42..7697f0c8 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt @@ -7,10 +7,35 @@ import com.openlayer.api.services.blocking.InferencePipelineService import com.openlayer.api.services.blocking.ProjectService import com.openlayer.api.services.blocking.StorageService +/** + * A client for interacting with the Openlayer REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface OpenlayerClient { + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun async(): OpenlayerClientAsync + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun projects(): ProjectService fun commits(): CommitService @@ -18,4 +43,29 @@ interface OpenlayerClient { fun inferencePipelines(): InferencePipelineService fun storage(): StorageService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** A view of [OpenlayerClient] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun projects(): ProjectService.WithRawResponse + + fun commits(): CommitService.WithRawResponse + + fun inferencePipelines(): InferencePipelineService.WithRawResponse + + fun storage(): StorageService.WithRawResponse + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt index d9a6d7a1..cd90e546 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt @@ -7,10 +7,35 @@ import com.openlayer.api.services.async.InferencePipelineServiceAsync import com.openlayer.api.services.async.ProjectServiceAsync import com.openlayer.api.services.async.StorageServiceAsync +/** + * A client for interacting with the Openlayer REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ interface OpenlayerClientAsync { + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ fun sync(): OpenlayerClient + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun projects(): ProjectServiceAsync fun commits(): CommitServiceAsync @@ -18,4 +43,31 @@ interface OpenlayerClientAsync { fun inferencePipelines(): InferencePipelineServiceAsync fun storage(): StorageServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [OpenlayerClientAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun projects(): ProjectServiceAsync.WithRawResponse + + fun commits(): CommitServiceAsync.WithRawResponse + + fun inferencePipelines(): InferencePipelineServiceAsync.WithRawResponse + + fun storage(): StorageServiceAsync.WithRawResponse + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt index 9335e18a..1a5e1785 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt @@ -13,10 +13,7 @@ import com.openlayer.api.services.async.ProjectServiceAsyncImpl import com.openlayer.api.services.async.StorageServiceAsync import com.openlayer.api.services.async.StorageServiceAsyncImpl -class OpenlayerClientAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : OpenlayerClientAsync { +class OpenlayerClientAsyncImpl(private val clientOptions: ClientOptions) : OpenlayerClientAsync { private val clientOptionsWithUserAgent = if (clientOptions.headers.names().contains("User-Agent")) clientOptions @@ -29,6 +26,10 @@ constructor( // Pass the original clientOptions so that this client sets its own User-Agent. private val sync: OpenlayerClient by lazy { OpenlayerClientImpl(clientOptions) } + private val withRawResponse: OpenlayerClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -47,6 +48,8 @@ constructor( override fun sync(): OpenlayerClient = sync + override fun withRawResponse(): OpenlayerClientAsync.WithRawResponse = withRawResponse + override fun projects(): ProjectServiceAsync = projects override fun commits(): CommitServiceAsync = commits @@ -54,4 +57,35 @@ constructor( override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines override fun storage(): StorageServiceAsync = storage + + override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OpenlayerClientAsync.WithRawResponse { + + private val projects: ProjectServiceAsync.WithRawResponse by lazy { + ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val commits: CommitServiceAsync.WithRawResponse by lazy { + CommitServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val inferencePipelines: InferencePipelineServiceAsync.WithRawResponse by lazy { + InferencePipelineServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val storage: StorageServiceAsync.WithRawResponse by lazy { + StorageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun projects(): ProjectServiceAsync.WithRawResponse = projects + + override fun commits(): CommitServiceAsync.WithRawResponse = commits + + override fun inferencePipelines(): InferencePipelineServiceAsync.WithRawResponse = + inferencePipelines + + override fun storage(): StorageServiceAsync.WithRawResponse = storage + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt index 4577ea48..f11b7575 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt @@ -13,10 +13,7 @@ import com.openlayer.api.services.blocking.ProjectServiceImpl import com.openlayer.api.services.blocking.StorageService import com.openlayer.api.services.blocking.StorageServiceImpl -class OpenlayerClientImpl -constructor( - private val clientOptions: ClientOptions, -) : OpenlayerClient { +class OpenlayerClientImpl(private val clientOptions: ClientOptions) : OpenlayerClient { private val clientOptionsWithUserAgent = if (clientOptions.headers.names().contains("User-Agent")) clientOptions @@ -29,6 +26,10 @@ constructor( // Pass the original clientOptions so that this client sets its own User-Agent. private val async: OpenlayerClientAsync by lazy { OpenlayerClientAsyncImpl(clientOptions) } + private val withRawResponse: OpenlayerClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } private val commits: CommitService by lazy { CommitServiceImpl(clientOptionsWithUserAgent) } @@ -41,6 +42,8 @@ constructor( override fun async(): OpenlayerClientAsync = async + override fun withRawResponse(): OpenlayerClient.WithRawResponse = withRawResponse + override fun projects(): ProjectService = projects override fun commits(): CommitService = commits @@ -48,4 +51,35 @@ constructor( override fun inferencePipelines(): InferencePipelineService = inferencePipelines override fun storage(): StorageService = storage + + override fun close() = clientOptions.httpClient.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + OpenlayerClient.WithRawResponse { + + private val projects: ProjectService.WithRawResponse by lazy { + ProjectServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val commits: CommitService.WithRawResponse by lazy { + CommitServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val inferencePipelines: InferencePipelineService.WithRawResponse by lazy { + InferencePipelineServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val storage: StorageService.WithRawResponse by lazy { + StorageServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun projects(): ProjectService.WithRawResponse = projects + + override fun commits(): CommitService.WithRawResponse = commits + + override fun inferencePipelines(): InferencePipelineService.WithRawResponse = + inferencePipelines + + override fun storage(): StorageService.WithRawResponse = storage + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt index 0573e162..e624381e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt @@ -7,7 +7,6 @@ import com.fasterxml.jackson.databind.BeanProperty import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer @@ -18,7 +17,7 @@ abstract class BaseDeserializer(type: KClass) : override fun createContextual( context: DeserializationContext, - property: BeanProperty? + property: BeanProperty?, ): JsonDeserializer { return this } @@ -29,31 +28,17 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {} - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {} - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Check.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Check.kt new file mode 100644 index 00000000..efcc5521 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Check.kt @@ -0,0 +1,91 @@ +@file:JvmName("Check") + +package com.openlayer.api.core + +import com.fasterxml.jackson.core.Version +import com.fasterxml.jackson.core.util.VersionUtil + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkJacksonVersionCompatibility() { + val incompatibleJacksonVersions = + RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] + when { + it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> + it to "incompatible major version" + it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> + it to "minor version too low" + it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && + it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> + it to "patch version too low" + badVersionReason != null -> it to badVersionReason + else -> null + } + } + check(incompatibleJacksonVersions.isEmpty()) { + """ +This SDK depends on Jackson version $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: + +${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> + "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" +}.joinToString("\n")} + +This can happen if you are either: +1. Directly depending on different Jackson versions +2. Depending on some library that depends on different Jackson versions, potentially transitively + +Double-check that you are depending on compatible Jackson versions. + """ + .trimIndent() + } +} + +private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") +private val RUNTIME_JACKSON_VERSIONS: List = + listOf( + com.fasterxml.jackson.core.json.PackageVersion.VERSION, + com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION, + com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION, + ) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ClientOptions.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ClientOptions.kt index 9dbd51c6..37bbbb54 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ClientOptions.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ClientOptions.kt @@ -9,65 +9,107 @@ import com.openlayer.api.core.http.PhantomReachableClosingHttpClient import com.openlayer.api.core.http.QueryParams import com.openlayer.api.core.http.RetryingHttpClient import java.time.Clock +import java.util.Optional +import kotlin.jvm.optionals.getOrNull class ClientOptions private constructor( private val originalHttpClient: HttpClient, @get:JvmName("httpClient") val httpClient: HttpClient, + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, + @get:JvmName("timeout") val timeout: Timeout, @get:JvmName("maxRetries") val maxRetries: Int, - @get:JvmName("apiKey") val apiKey: String?, + private val apiKey: String?, ) { + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + + fun apiKey(): Optional = Optional.ofNullable(apiKey) + fun toBuilder() = Builder().from(this) companion object { const val PRODUCTION_URL = "https://api.openlayer.com/v1" + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * ``` + */ @JvmStatic fun builder() = Builder() @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() } - class Builder { + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { private var httpClient: HttpClient? = null + private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() private var clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 private var apiKey: String? = null @JvmSynthetic internal fun from(clientOptions: ClientOptions) = apply { httpClient = clientOptions.originalHttpClient + checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() queryParams = clientOptions.queryParams.toBuilder() responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries apiKey = clientOptions.apiKey } fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } fun clock(clock: Clock) = apply { this.clock = clock } fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } + + /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ + fun apiKey(apiKey: Optional) = apiKey(apiKey.getOrNull()) + fun headers(headers: Headers) = apply { this.headers.clear() putAllHeaders(headers) @@ -148,18 +190,27 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } - - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - - fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey } - - fun fromEnv() = apply { System.getenv("OPENLAYER_API_KEY")?.let { apiKey(it) } } - + fun baseUrl(): String = baseUrl + + fun fromEnv() = apply { + System.getenv("OPENLAYER_BASE_URL")?.let { baseUrl(it) } + System.getenv("OPENLAYER_API_KEY")?.let { apiKey(it) } + } + + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): ClientOptions { - checkNotNull(httpClient) { "`httpClient` is required but was not set" } + val httpClient = checkRequired("httpClient", httpClient) val headers = Headers.builder() val queryParams = QueryParams.builder() @@ -179,20 +230,22 @@ private constructor( queryParams.replaceAll(this.queryParams.build()) return ClientOptions( - httpClient!!, + httpClient, PhantomReachableClosingHttpClient( RetryingHttpClient.builder() - .httpClient(httpClient!!) + .httpClient(httpClient) .clock(clock) .maxRetries(maxRetries) .build() ), + checkJacksonVersionCompatibility, jsonMapper, clock, baseUrl, headers.build(), queryParams.build(), responseValidation, + timeout, maxRetries, apiKey, ) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/HttpRequestBodies.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/HttpRequestBodies.kt deleted file mode 100644 index 8838f20c..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/HttpRequestBodies.kt +++ /dev/null @@ -1,111 +0,0 @@ -@file:JvmName("HttpRequestBodies") - -package com.openlayer.api.core - -import com.fasterxml.jackson.databind.json.JsonMapper -import com.openlayer.api.core.http.HttpRequestBody -import com.openlayer.api.errors.OpenlayerException -import java.io.ByteArrayOutputStream -import java.io.OutputStream -import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder - -@JvmSynthetic -internal inline fun json( - jsonMapper: JsonMapper, - value: T, -): HttpRequestBody { - return object : HttpRequestBody { - private var cachedBytes: ByteArray? = null - - private fun serialize(): ByteArray { - if (cachedBytes != null) return cachedBytes!! - - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, value) - cachedBytes = buffer.toByteArray() - return cachedBytes!! - } catch (e: Exception) { - throw OpenlayerException("Error writing request", e) - } - } - - override fun writeTo(outputStream: OutputStream) { - outputStream.write(serialize()) - } - - override fun contentType(): String = "application/json" - - override fun contentLength(): Long { - return serialize().size.toLong() - } - - override fun repeatable(): Boolean = true - - override fun close() {} - } -} - -@JvmSynthetic -internal fun multipartFormData( - jsonMapper: JsonMapper, - parts: Array?> -): HttpRequestBody { - val builder = MultipartEntityBuilder.create() - parts.forEach { part -> - if (part?.value != null) { - when (part.value) { - is JsonValue -> { - val buffer = ByteArrayOutputStream() - try { - jsonMapper.writeValue(buffer, part.value) - } catch (e: Exception) { - throw OpenlayerException("Error serializing value to json", e) - } - builder.addBinaryBody( - part.name, - buffer.toByteArray(), - part.contentType, - part.filename - ) - } - is Boolean -> - builder.addTextBody( - part.name, - if (part.value) "true" else "false", - part.contentType - ) - is Int -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Long -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is Double -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - is ByteArray -> - builder.addBinaryBody(part.name, part.value, part.contentType, part.filename) - is String -> builder.addTextBody(part.name, part.value, part.contentType) - is Enum -> builder.addTextBody(part.name, part.value.toString(), part.contentType) - else -> - throw IllegalArgumentException( - "Unsupported content type: ${part.value::class.java.simpleName}" - ) - } - } - } - val entity = builder.build() - - return object : HttpRequestBody { - override fun writeTo(outputStream: OutputStream) { - try { - return entity.writeTo(outputStream) - } catch (e: Exception) { - throw OpenlayerException("Error writing request", e) - } - } - - override fun contentType(): String = entity.contentType - - override fun contentLength(): Long = -1 - - override fun repeatable(): Boolean = entity.isRepeatable - - override fun close() = entity.close() - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ObjectMappers.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ObjectMappers.kt index 2a22f38a..1438d8ea 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ObjectMappers.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/ObjectMappers.kt @@ -3,23 +3,165 @@ package com.openlayer.api.core import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.MapperFeature import com.fasterxml.jackson.databind.SerializationFeature -import com.fasterxml.jackson.databind.cfg.CoercionAction.Fail -import com.fasterxml.jackson.databind.cfg.CoercionInputShape.Integer +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType import com.fasterxml.jackson.datatype.jdk8.Jdk8Module import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder +import com.fasterxml.jackson.module.kotlin.kotlinModule +import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField fun jsonMapper(): JsonMapper = - jacksonMapperBuilder() + JsonMapper.builder() + .addModule(kotlinModule()) .addModule(Jdk8Module()) .addModule(JavaTimeModule()) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } .serializationInclusion(JsonInclude.Include.NON_ABSENT) .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) - .withCoercionConfig(String::class.java) { it.setCoercion(Integer, Fail) } + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS) + .disable(MapperFeature.AUTO_DETECT_GETTERS) + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) + .disable(MapperFeature.AUTO_DETECT_SETTERS) .build() + +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Params.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Params.kt new file mode 100644 index 00000000..62cbb730 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Params.kt @@ -0,0 +1,16 @@ +package com.openlayer.api.core + +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/PrepareRequest.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/PrepareRequest.kt new file mode 100644 index 00000000..adf85bd8 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package com.openlayer.api.core + +import com.openlayer.api.core.http.HttpRequest +import java.util.concurrent.CompletableFuture + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params, +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/RequestOptions.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/RequestOptions.kt index 2b862a37..5ca3fddb 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/RequestOptions.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/RequestOptions.kt @@ -2,17 +2,7 @@ package com.openlayer.api.core import java.time.Duration -class RequestOptions -private constructor( - val responseValidation: Boolean?, - val timeout: Duration?, -) { - fun applyDefaults(options: RequestOptions): RequestOptions { - return RequestOptions( - responseValidation = this.responseValidation ?: options.responseValidation, - timeout = this.timeout ?: options.timeout, - ) - } +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { companion object { @@ -20,21 +10,37 @@ private constructor( @JvmStatic fun none() = NONE + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + @JvmStatic fun builder() = Builder() } - class Builder { + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + + class Builder internal constructor() { + private var responseValidation: Boolean? = null - private var timeout: Duration? = null + private var timeout: Timeout? = null fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } - fun timeout(timeout: Duration) = apply { this.timeout = timeout } + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } - fun build(): RequestOptions { - return RequestOptions(responseValidation, timeout) - } + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Timeout.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Timeout.kt new file mode 100644 index 00000000..e07cad54 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Timeout.kt @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ + fun connect(connect: Optional) = connect(connect.getOrNull()) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ + fun read(read: Optional) = read(read.getOrNull()) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ + fun write(write: Optional) = write(write.getOrNull()) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ + fun request(request: Optional) = request(request.getOrNull()) + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Timeout && connect == other.connect && read == other.read && write == other.write && request == other.request /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(connect, read, write, request) /* spotless:on */ + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt index 7c5ab9d7..4482ae3d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt @@ -16,11 +16,77 @@ internal fun List.toImmutable(): List = @JvmSynthetic internal fun Map.toImmutable(): Map = - if (isEmpty()) Collections.emptyMap() else Collections.unmodifiableMap(toMap()) + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() @JvmSynthetic internal fun , V> SortedMap.toImmutable(): SortedMap = if (isEmpty()) Collections.emptySortedMap() else Collections.unmodifiableSortedMap(toSortedMap(comparator())) +/** + * Returns all elements that yield the largest value for the given function, or an empty list if + * there are zero elements. + * + * This is similar to [Sequence.maxByOrNull] except it returns _all_ elements that yield the largest + * value; not just the first one. + */ +@JvmSynthetic +internal fun > Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + +/** + * Returns whether [this] is equal to [other]. + * + * This differs from [Object.equals] because it also deeply equates arrays based on their contents, + * even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal infix fun Any?.contentEquals(other: Any?): Boolean = + arrayOf(this).contentDeepEquals(arrayOf(other)) + +/** + * Returns a hash of the given sequence of [values]. + * + * This differs from [java.util.Objects.hash] because it also deeply hashes arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic internal fun contentHash(vararg values: Any?): Int = values.contentDeepHashCode() + +/** + * Returns a [String] representation of [this]. + * + * This differs from [Object.toString] because it also deeply stringifies arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal fun Any?.contentToString(): String { + var string = arrayOf(this).contentDeepToString() + if (string.startsWith('[')) { + string = string.substring(1) + } + if (string.endsWith(']')) { + string = string.substring(0, string.length - 1) + } + return string +} + internal interface Enum diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt index fc2653eb..88f25c14 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Values.kt @@ -1,8 +1,6 @@ package com.openlayer.api.core import com.fasterxml.jackson.annotation.JacksonAnnotationsInside -import com.fasterxml.jackson.annotation.JsonAutoDetect -import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.core.JsonGenerator @@ -27,68 +25,145 @@ import com.fasterxml.jackson.databind.node.JsonNodeType.POJO import com.fasterxml.jackson.databind.node.JsonNodeType.STRING import com.fasterxml.jackson.databind.ser.std.NullSerializer import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.nio.charset.Charset +import java.io.InputStream import java.util.Objects import java.util.Optional -import org.apache.hc.core5.http.ContentType +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ @JsonDeserialize(using = JsonField.Deserializer::class) sealed class JsonField { + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ fun isMissing(): Boolean = this is JsonMissing + /** Whether this field is explicitly set to `null`. */ fun isNull(): Boolean = this is JsonNull - fun asKnown(): Optional = - when (this) { - is KnownValue -> Optional.of(value) - else -> Optional.empty() - } + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) /** - * If the "known" value (i.e. matching the type that the SDK expects) is returned by the API - * then this method will return an empty `Optional`, otherwise the returned `Optional` is given - * a `JsonValue`. + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. */ - fun asUnknown(): Optional = - when (this) { - is JsonValue -> Optional.of(this) - else -> Optional.empty() - } + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ fun asBoolean(): Optional = when (this) { is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ fun asNumber(): Optional = when (this) { is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ fun asString(): Optional = when (this) { is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) else -> Optional.empty() } fun asStringOrThrow(): String = - when (this) { - is JsonString -> value - else -> throw OpenlayerInvalidDataException("Value is not a string") - } + asString().orElseThrow { OpenlayerInvalidDataException("Value is not a string") } + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ fun asArray(): Optional> = when (this) { is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) else -> Optional.empty() } + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ fun asObject(): Optional> = when (this) { is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) else -> Optional.empty() } @@ -96,18 +171,24 @@ sealed class JsonField { internal fun getRequired(name: String): T = when (this) { is KnownValue -> value - is JsonMissing -> throw OpenlayerInvalidDataException("'${name}' is not set") - is JsonNull -> throw OpenlayerInvalidDataException("'${name}' is null") - else -> throw OpenlayerInvalidDataException("'${name}' is invalid, received ${this}") + is JsonMissing -> throw OpenlayerInvalidDataException("`$name` is not set") + is JsonNull -> throw OpenlayerInvalidDataException("`$name` is null") + else -> throw OpenlayerInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic - internal fun getNullable(name: String): T? = + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = when (this) { - is KnownValue -> value - is JsonMissing -> null - is JsonNull -> null - else -> throw OpenlayerInvalidDataException("'${name}' is invalid, received ${this}") + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw OpenlayerInvalidDataException("`$name` is invalid, received $this") } @JvmSynthetic @@ -117,19 +198,33 @@ sealed class JsonField { is JsonValue -> this } + @JvmSynthetic internal fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + + /** Returns the result of calling the [visitor] method corresponding to this field's state. */ fun accept(visitor: Visitor): R = when (this) { is KnownValue -> visitor.visitKnown(value) is JsonValue -> accept(visitor as JsonValue.Visitor) } + /** + * An interface that defines how to map each possible state of a `JsonField` to a value of + * type [R]. + */ interface Visitor : JsonValue.Visitor { + fun visitKnown(value: T): R = visitDefault() } companion object { + + /** Returns a [JsonField] containing the given "known" [value]. */ @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + /** + * Returns a [JsonField] containing the given "known" [value], or [JsonNull] if [value] is + * null. + */ @JvmStatic fun ofNullable(value: T?): JsonField = when (value) { @@ -138,9 +233,13 @@ sealed class JsonField { } } - // This class is a Jackson filter that can be used to exclude missing properties from objects - // This filter should not be used directly and should instead use the @ExcludeMissing annotation + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ class IsMissing { + override fun equals(other: Any?): Boolean = other is JsonMissing override fun hashCode(): Int = Objects.hash() @@ -152,21 +251,22 @@ sealed class JsonField { override fun createContextual( context: DeserializationContext, property: BeanProperty?, - ): JsonDeserializer> { - return Deserializer(context.contextualType?.containedType(0)) - } + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) - override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { - return type?.let { tryDeserialize(node, type) }?.let { of(it) } + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } ?: JsonValue.fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext): JsonField<*> { - return JsonNull.of() - } + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() } } +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ @JsonDeserialize(using = JsonValue.Deserializer::class) sealed class JsonValue : JsonField() { @@ -174,6 +274,7 @@ sealed class JsonValue : JsonField() { fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ fun accept(visitor: Visitor): R = when (this) { is JsonMissing -> visitor.visitMissing() @@ -185,7 +286,12 @@ sealed class JsonValue : JsonField() { is JsonObject -> visitor.visitObject(values) } + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ interface Visitor { + fun visitNull(): R = visitDefault() fun visitMissing(): R = visitDefault() @@ -200,15 +306,52 @@ sealed class JsonValue : JsonField() { fun visitObject(values: Map): R = visitDefault() - fun visitDefault(): R { - throw RuntimeException("Unexpected value") - } + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") } companion object { private val JSON_MAPPER = jsonMapper() + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ @JvmStatic fun from(value: Any?): JsonValue = when (value) { @@ -217,6 +360,11 @@ sealed class JsonValue : JsonField() { else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) } + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ @JvmStatic fun fromJsonNode(node: JsonNode): JsonValue = when (node.nodeType) { @@ -238,16 +386,19 @@ sealed class JsonValue : JsonField() { } class Deserializer : BaseDeserializer(JsonValue::class) { - override fun ObjectCodec.deserialize(node: JsonNode): JsonValue { - return fromJsonNode(node) - } - override fun getNullValue(context: DeserializationContext?): JsonValue { - return JsonNull.of() - } + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() } } +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `JsonField`. + */ class KnownValue private constructor( @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T @@ -258,52 +409,67 @@ private constructor( return true } - return other is KnownValue<*> && value == other.value + return other is KnownValue<*> && value contentEquals other.value } - override fun hashCode() = value.hashCode() + override fun hashCode() = contentHash(value) - override fun toString() = value.toString() + override fun toString() = value.contentToString() companion object { + + /** Returns a [KnownValue] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) } } +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ @JsonSerialize(using = JsonMissing.Serializer::class) class JsonMissing : JsonValue() { override fun toString() = "" companion object { + private val INSTANCE: JsonMissing = JsonMissing() + /** Returns the singleton instance of [JsonMissing]. */ @JvmStatic fun of() = INSTANCE } class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( value: JsonMissing, generator: JsonGenerator, - provider: SerializerProvider + provider: SerializerProvider, ) { - throw RuntimeException("JsonMissing cannot be serialized") + throw IllegalStateException("JsonMissing cannot be serialized") } } } +/** A [JsonValue] representing a JSON `null` value. */ @JsonSerialize(using = NullSerializer::class) class JsonNull : JsonValue() { override fun toString() = "null" companion object { + private val INSTANCE: JsonNull = JsonNull() + /** Returns the singleton instance of [JsonMissing]. */ @JsonCreator @JvmStatic fun of() = INSTANCE } } +/** A [JsonValue] representing a JSON boolean value. */ class JsonBoolean private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean @@ -322,14 +488,18 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) } } +/** A [JsonValue] representing a JSON number value. */ class JsonNumber private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number ) : JsonValue() { + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -343,10 +513,13 @@ private constructor( override fun toString() = value.toString() companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) } } +/** A [JsonValue] representing a JSON string value. */ class JsonString private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String @@ -365,10 +538,13 @@ private constructor( override fun toString() = value companion object { + + /** Returns a [JsonString] containing the given [value]. */ @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) } } +/** A [JsonValue] representing a JSON array value. */ class JsonArray private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -389,10 +565,13 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonArray] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) } } +/** A [JsonValue] representing a JSON object value. */ class JsonObject private constructor( @get:com.fasterxml.jackson.annotation.JsonValue @@ -413,124 +592,132 @@ private constructor( override fun toString() = values.toString() companion object { + + /** Returns a [JsonObject] containing the given [values]. */ @JsonCreator @JvmStatic fun of(values: Map) = JsonObject(values.toImmutable()) } } +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ @JacksonAnnotationsInside -@JsonInclude( - JsonInclude.Include.CUSTOM, - valueFilter = JsonField.IsMissing::class, -) +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) annotation class ExcludeMissing -@JacksonAnnotationsInside -@JsonAutoDetect( - getterVisibility = Visibility.NONE, - isGetterVisibility = Visibility.NONE, - setterVisibility = Visibility.NONE, - creatorVisibility = Visibility.NONE, - fieldVisibility = Visibility.NONE -) -annotation class NoAutoDetect - -class MultipartFormValue -internal constructor( - val name: String, - val value: T, - val contentType: ContentType, - val filename: String? = null +/** A class representing a field in a `multipart/form-data` request. */ +class MultipartField +private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ + @get:JvmName("contentType") val contentType: String, + private val filename: String?, ) { - private var hashCode: Int = 0 - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - name, - contentType, - filename, - when (value) { - is ByteArray -> value.contentHashCode() - is String -> value - is Boolean -> value - is Long -> value - is Double -> value - else -> value?.hashCode() - } - ) - } - return hashCode - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other == null || this.javaClass != other.javaClass) return false + companion object { - other as MultipartFormValue<*> + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: T?) = builder().value(value).build() + + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun builder() = Builder() + } - if (name != other.name || contentType != other.contentType || filename != other.filename) - return false + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) - return when { - value is ByteArray && other.value is ByteArray -> value contentEquals other.value - else -> value?.equals(other.value) ?: (other.value == null) + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + builder().value(value.map(transform)).contentType(contentType).filename(filename).build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ + fun filename(filename: Optional) = filename(filename.orElse(null)) + + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) } } - override fun toString(): String = - "MultipartFormValue{name=$name, contentType=$contentType, filename=$filename, value=${valueToString()}}" + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode - private fun valueToString(): String = - when (value) { - is ByteArray -> "ByteArray of size ${value.size}" - else -> value.toString() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - companion object { - internal fun fromString( - name: String, - value: String, - contentType: ContentType - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromBoolean( - name: String, - value: Boolean, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromLong( - name: String, - value: Long, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromDouble( - name: String, - value: Double, - contentType: ContentType, - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromEnum( - name: String, - value: T, - contentType: ContentType - ): MultipartFormValue = MultipartFormValue(name, value, contentType) - - internal fun fromByteArray( - name: String, - value: ByteArray, - contentType: ContentType, - filename: String? = null - ): MultipartFormValue = MultipartFormValue(name, value, contentType, filename) + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename } -} -internal object ContentTypes { - val DefaultText = ContentType.create(ContentType.TEXT_PLAIN.mimeType, Charset.forName("UTF-8")) - val DefaultBinary = ContentType.DEFAULT_BINARY + override fun toString(): String = + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt index 5e442089..52ca7bb6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt @@ -1,125 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + @file:JvmName("ErrorHandler") package com.openlayer.api.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.http.HttpResponse import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.errors.BadRequestException import com.openlayer.api.errors.InternalServerException import com.openlayer.api.errors.NotFoundException -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.errors.PermissionDeniedException import com.openlayer.api.errors.RateLimitException import com.openlayer.api.errors.UnauthorizedException import com.openlayer.api.errors.UnexpectedStatusCodeException import com.openlayer.api.errors.UnprocessableEntityException -import java.io.ByteArrayInputStream -import java.io.InputStream @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { - val handler = jsonHandler(jsonMapper) +internal fun errorHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) - return object : Handler { - override fun handle(response: HttpResponse): OpenlayerError = + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = try { handler.handle(response) } catch (e: Exception) { - OpenlayerError.builder().build() + JsonMissing.of() } } } @JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = +internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = when (val statusCode = response.statusCode()) { - in 200..299 -> { - return this@withErrorHandler.handle(response) - } - 400 -> { - val buffered = response.buffered() - throw BadRequestException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 401 -> { - val buffered = response.buffered() - throw UnauthorizedException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 403 -> { - val buffered = response.buffered() - throw PermissionDeniedException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 404 -> { - val buffered = response.buffered() - throw NotFoundException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 422 -> { - val buffered = response.buffered() - throw UnprocessableEntityException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - 429 -> { - val buffered = response.buffered() - throw RateLimitException( - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - in 500..599 -> { - val buffered = response.buffered() - throw InternalServerException( - statusCode, - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } - else -> { - val buffered = response.buffered() - throw UnexpectedStatusCodeException( - statusCode, - buffered.headers(), - stringHandler().handle(buffered), - errorHandler.handle(buffered), - ) - } + in 200..299 -> this@withErrorHandler.handle(response) + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorHandler.handle(response)) + .build() } - } - } - -private fun HttpResponse.buffered(): HttpResponse { - val body = body().readBytes() - - return object : HttpResponse { - override fun statusCode(): Int = this@buffered.statusCode() - - override fun headers(): Headers = this@buffered.headers() - - override fun body(): InputStream = ByteArrayInputStream(body) - - override fun close() = this@buffered.close() } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/JsonHandler.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/JsonHandler.kt index 6babe3b3..a020c1c1 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/JsonHandler.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/JsonHandler.kt @@ -6,16 +6,15 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openlayer.api.core.http.HttpResponse import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.errors.OpenlayerException +import com.openlayer.api.errors.OpenlayerInvalidDataException @JvmSynthetic internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = try { - return jsonMapper.readValue(response.body(), jacksonTypeRef()) + jsonMapper.readValue(response.body(), jacksonTypeRef()) } catch (e: Exception) { - throw OpenlayerException("Error reading response", e) + throw OpenlayerInvalidDataException("Error reading response", e) } - } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/Headers.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/Headers.kt index 8b934c1b..b4230b87 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/Headers.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/Headers.kt @@ -6,7 +6,7 @@ import java.util.TreeMap class Headers private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -22,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = TreeMap(String.CASE_INSENSITIVE_ORDER) @@ -74,7 +74,7 @@ private constructor( values.toImmutable() } .toImmutable(), - size + size, ) } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpClient.kt index bed23ad7..49aca933 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpClient.kt @@ -1,5 +1,3 @@ -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.core.http import com.openlayer.api.core.RequestOptions @@ -8,15 +6,21 @@ import java.util.concurrent.CompletableFuture interface HttpClient : AutoCloseable { - @JvmOverloads fun execute( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - @JvmOverloads + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + fun executeAsync( request: HttpRequest, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequest.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequest.kt index 1acfcbc8..348bd8d7 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequest.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequest.kt @@ -1,5 +1,6 @@ package com.openlayer.api.core.http +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.toImmutable class HttpRequest @@ -21,7 +22,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var method: HttpMethod? = null private var url: String? = null @@ -134,7 +135,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( - checkNotNull(method) { "`method` is required but was not set" }, + checkRequired("method", method), url, pathSegments.toImmutable(), headers.build(), diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBodies.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBodies.kt new file mode 100644 index 00000000..39005535 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBodies.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package com.openlayer.api.core.http + +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import com.openlayer.api.core.MultipartField +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.io.InputStream +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().inputStream()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().inputStream()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> node.textValue() + JsonNodeType.BOOLEAN -> node.booleanValue().toString() + JsonNodeType.NUMBER -> node.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw OpenlayerInvalidDataException( + "Unexpected JsonNode type in array: ${node.nodeType}" + ) + } + } + .joinToString(",") + .inputStream() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw OpenlayerInvalidDataException( + "Unexpected JsonNode type: ${node.nodeType}" + ) + } + + private fun String.inputStream(): InputStream = toByteArray().inputStream() + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBody.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBody.kt index 32b5f81f..51670e75 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBody.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpRequestBody.kt @@ -1,12 +1,11 @@ package com.openlayer.api.core.http -import java.io.IOException import java.io.OutputStream import java.lang.AutoCloseable interface HttpRequestBody : AutoCloseable { - @Throws(IOException::class) fun writeTo(outputStream: OutputStream) + fun writeTo(outputStream: OutputStream) fun contentType(): String? @@ -21,5 +20,6 @@ interface HttpRequestBody : AutoCloseable { */ fun repeatable(): Boolean + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ override fun close() } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponse.kt index 098bc985..c3e59f67 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponse.kt @@ -1,7 +1,8 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.core.http import java.io.InputStream -import java.lang.AutoCloseable interface HttpResponse : AutoCloseable { @@ -11,6 +12,9 @@ interface HttpResponse : AutoCloseable { fun body(): InputStream + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() + interface Handler { fun handle(response: HttpResponse): T diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponseFor.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponseFor.kt new file mode 100644 index 00000000..3ef21016 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/HttpResponseFor.kt @@ -0,0 +1,25 @@ +package com.openlayer.api.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + private val parsed: T by lazy { parse() } + + override fun parse(): T = parsed + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/PhantomReachableClosingHttpClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/PhantomReachableClosingHttpClient.kt index ab4266ee..75813146 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/PhantomReachableClosingHttpClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/PhantomReachableClosingHttpClient.kt @@ -4,6 +4,11 @@ import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.closeWhenPhantomReachable import java.util.concurrent.CompletableFuture +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { init { closeWhenPhantomReachable(this, httpClient) @@ -14,7 +19,7 @@ internal class PhantomReachableClosingHttpClient(private val httpClient: HttpCli override fun executeAsync( request: HttpRequest, - requestOptions: RequestOptions + requestOptions: RequestOptions, ): CompletableFuture = httpClient.executeAsync(request, requestOptions) override fun close() = httpClient.close() diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/QueryParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/QueryParams.kt index 4a53fb0a..8810d781 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/QueryParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/QueryParams.kt @@ -1,3 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.core.http import com.openlayer.api.core.toImmutable @@ -5,7 +7,7 @@ import com.openlayer.api.core.toImmutable class QueryParams private constructor( private val map: Map>, - @get:JvmName("size") val size: Int + @get:JvmName("size") val size: Int, ) { fun isEmpty(): Boolean = map.isEmpty() @@ -21,7 +23,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private val map: MutableMap> = mutableMapOf() private var size: Int = 0 diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt index 56feff5c..63da1cea 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,7 @@ package com.openlayer.api.core.http import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired import com.openlayer.api.errors.OpenlayerIoException import java.io.IOException import java.time.Clock @@ -27,10 +28,7 @@ private constructor( private val idempotencyHeader: String?, ) : HttpClient { - override fun execute( - request: HttpRequest, - requestOptions: RequestOptions, - ): HttpResponse { + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { if (!isRetryable(request) || maxRetries <= 0) { return httpClient.execute(request, requestOptions) } @@ -56,15 +54,17 @@ private constructor( } response - } catch (t: Throwable) { - if (++retries > maxRetries || !shouldRetry(t)) { - throw t + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable } null } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() Thread.sleep(backoffMillis.toMillis()) } } @@ -97,7 +97,7 @@ private constructor( .handleAsync( fun( response: HttpResponse?, - throwable: Throwable? + throwable: Throwable?, ): CompletableFuture { if (response != null) { if (++retries > maxRetries || !shouldRetry(response)) { @@ -112,10 +112,12 @@ private constructor( } val backoffMillis = getRetryBackoffMillis(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() return sleepAsync(backoffMillis.toMillis()).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } - }, + } ) { // Run in the same thread. it.run() @@ -195,8 +197,8 @@ private constructor( OffsetDateTime.now(clock), OffsetDateTime.parse( retryAfter, - DateTimeFormatter.RFC_1123_DATE_TIME - ) + DateTimeFormatter.RFC_1123_DATE_TIME, + ), ) } catch (e: DateTimeParseException) { null @@ -222,27 +224,27 @@ private constructor( return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) } - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis - ) - return future - } - companion object { private val TIMER = Timer("RetryingHttpClient", true) + private fun sleepAsync(millis: Long): CompletableFuture { + val future = CompletableFuture() + TIMER.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + millis, + ) + return future + } + @JvmStatic fun builder() = Builder() } - class Builder { + class Builder internal constructor() { private var httpClient: HttpClient? = null private var clock: Clock = Clock.systemUTC() @@ -259,7 +261,7 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( - checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + checkRequired("httpClient", httpClient), clock, maxRetries, idempotencyHeader, diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt index cddebd08..9acdcaa2 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BadRequestException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("400: $body", cause) { + + override fun statusCode(): Int = 400 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BadRequestException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BadRequestException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(badRequestException: BadRequestException) = apply { + headers = badRequestException.headers + body = badRequestException.body + cause = badRequestException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class BadRequestException( - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(400, headers, body, error) + /** + * Returns an immutable instance of [BadRequestException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BadRequestException = + BadRequestException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt index ba8c9119..aca354d8 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt @@ -1,10 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InternalServerException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : OpenlayerServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalServerException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalServerException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(internalServerException: InternalServerException) = apply { + statusCode = internalServerException.statusCode + headers = internalServerException.headers + body = internalServerException.body + cause = internalServerException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class InternalServerException( - statusCode: Int, - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(statusCode, headers, body, error) + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt index 0786e638..4bf98a53 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt @@ -1,9 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotFoundException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("404: $body", cause) { + + override fun statusCode(): Int = 404 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotFoundException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotFoundException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(notFoundException: NotFoundException) = apply { + headers = notFoundException.headers + body = notFoundException.body + cause = notFoundException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class NotFoundException( - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(404, headers, body, error) + /** + * Returns an immutable instance of [NotFoundException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt deleted file mode 100644 index 0376b43e..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.errors - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import java.util.Objects - -@JsonDeserialize(builder = OpenlayerError.Builder::class) -@NoAutoDetect -class OpenlayerError -private constructor( - @JsonAnyGetter - @get:JvmName("additionalProperties") - val additionalProperties: Map, -) { - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(openlayerError: OpenlayerError) = apply { - additionalProperties = openlayerError.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - fun build(): OpenlayerError = OpenlayerError(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OpenlayerError && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - - override fun toString() = "OpenlayerError{additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt index 586f9be6..69a2cf0b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt @@ -1,23 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.http.Headers abstract class OpenlayerServiceException -@JvmOverloads -constructor( - private val statusCode: Int, - private val headers: Headers, - private val body: String, - private val error: OpenlayerError, - message: String = "$statusCode: $error", - cause: Throwable? = null -) : OpenlayerException(message, cause) { - - fun statusCode(): Int = statusCode +protected constructor(message: String, cause: Throwable? = null) : + OpenlayerException(message, cause) { - fun headers(): Headers = headers + abstract fun statusCode(): Int - fun body(): String = body + abstract fun headers(): Headers - fun error(): OpenlayerError = error + abstract fun body(): JsonValue } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt index 89f54d4e..844dd555 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PermissionDeniedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("403: $body", cause) { + + override fun statusCode(): Int = 403 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PermissionDeniedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PermissionDeniedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(permissionDeniedException: PermissionDeniedException) = apply { + headers = permissionDeniedException.headers + body = permissionDeniedException.body + cause = permissionDeniedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class PermissionDeniedException( - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(403, headers, body, error) + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt index 27bfad40..a3fba535 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RateLimitException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("429: $body", cause) { + + override fun statusCode(): Int = 429 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RateLimitException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RateLimitException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(rateLimitException: RateLimitException) = apply { + headers = rateLimitException.headers + body = rateLimitException.body + cause = rateLimitException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class RateLimitException( - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(429, headers, body, error) + /** + * Returns an immutable instance of [RateLimitException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt index ba6f77e7..ead1e7c7 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnauthorizedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("401: $body", cause) { + + override fun statusCode(): Int = 401 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnauthorizedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnauthorizedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unauthorizedException: UnauthorizedException) = apply { + headers = unauthorizedException.headers + body = unauthorizedException.body + cause = unauthorizedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class UnauthorizedException( - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(401, headers, body, error) + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt index b4cab62c..e8ed72b9 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnexpectedStatusCodeException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : OpenlayerServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnexpectedStatusCodeException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnexpectedStatusCodeException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unexpectedStatusCodeException: UnexpectedStatusCodeException) = apply { + statusCode = unexpectedStatusCodeException.statusCode + headers = unexpectedStatusCodeException.headers + body = unexpectedStatusCodeException.body + cause = unexpectedStatusCodeException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class UnexpectedStatusCodeException( - statusCode: Int, - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(statusCode, headers, body, error) + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt index e7d2ecd8..10abb5a2 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt @@ -1,9 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnprocessableEntityException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("422: $body", cause) { + + override fun statusCode(): Int = 422 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnprocessableEntityException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnprocessableEntityException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unprocessableEntityException: UnprocessableEntityException) = apply { + headers = unprocessableEntityException.headers + body = unprocessableEntityException.body + cause = unprocessableEntityException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) -class UnprocessableEntityException( - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(422, headers, body, error) + /** + * Returns an immutable instance of [UnprocessableEntityException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnprocessableEntityException = + UnprocessableEntityException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitTestResultListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitTestResultListParams.kt deleted file mode 100644 index 483a9ee2..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitTestResultListParams.kt +++ /dev/null @@ -1,395 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonCreator -import com.openlayer.api.core.Enum -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.util.Objects -import java.util.Optional - -class CommitTestResultListParams -constructor( - private val projectVersionId: String, - private val includeArchived: Boolean?, - private val page: Long?, - private val perPage: Long?, - private val status: Status?, - private val type: Type?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) { - - fun projectVersionId(): String = projectVersionId - - fun includeArchived(): Optional = Optional.ofNullable(includeArchived) - - fun page(): Optional = Optional.ofNullable(page) - - fun perPage(): Optional = Optional.ofNullable(perPage) - - fun status(): Optional = Optional.ofNullable(status) - - fun type(): Optional = Optional.ofNullable(type) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.includeArchived?.let { queryParams.put("includeArchived", listOf(it.toString())) } - this.page?.let { queryParams.put("page", listOf(it.toString())) } - this.perPage?.let { queryParams.put("perPage", listOf(it.toString())) } - this.status?.let { queryParams.put("status", listOf(it.toString())) } - this.type?.let { queryParams.put("type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectVersionId - else -> "" - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var projectVersionId: String? = null - private var includeArchived: Boolean? = null - private var page: Long? = null - private var perPage: Long? = null - private var status: Status? = null - private var type: Type? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(commitTestResultListParams: CommitTestResultListParams) = apply { - projectVersionId = commitTestResultListParams.projectVersionId - includeArchived = commitTestResultListParams.includeArchived - page = commitTestResultListParams.page - perPage = commitTestResultListParams.perPage - status = commitTestResultListParams.status - type = commitTestResultListParams.type - additionalHeaders = commitTestResultListParams.additionalHeaders.toBuilder() - additionalQueryParams = commitTestResultListParams.additionalQueryParams.toBuilder() - } - - fun projectVersionId(projectVersionId: String) = apply { - this.projectVersionId = projectVersionId - } - - /** Include archived goals. */ - fun includeArchived(includeArchived: Boolean) = apply { - this.includeArchived = includeArchived - } - - /** The page to return in a paginated query. */ - fun page(page: Long) = apply { this.page = page } - - /** Maximum number of items to return per page. */ - fun perPage(perPage: Long) = apply { this.perPage = perPage } - - /** - * Filter list of test results by status. Available statuses are `running`, `passing`, - * `failing`, `skipped`, and `error`. - */ - fun status(status: Status) = apply { this.status = status } - - /** - * Filter objects by test type. Available types are `integrity`, `consistency`, - * `performance`, `fairness`, and `robustness`. - */ - fun type(type: Type) = apply { this.type = type } - - 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 build(): CommitTestResultListParams = - CommitTestResultListParams( - checkNotNull(projectVersionId) { "`projectVersionId` is required but was not set" }, - includeArchived, - page, - perPage, - status, - type, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val RUNNING = of("running") - - @JvmField val PASSING = of("passing") - - @JvmField val FAILING = of("failing") - - @JvmField val SKIPPED = of("skipped") - - @JvmField val ERROR = of("error") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - } - - enum class Value { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - RUNNING -> Value.RUNNING - PASSING -> Value.PASSING - FAILING -> Value.FAILING - SKIPPED -> Value.SKIPPED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - RUNNING -> Known.RUNNING - PASSING -> Known.PASSING - FAILING -> Known.FAILING - SKIPPED -> Known.SKIPPED - ERROR -> Known.ERROR - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INTEGRITY = of("integrity") - - @JvmField val CONSISTENCY = of("consistency") - - @JvmField val PERFORMANCE = of("performance") - - @JvmField val FAIRNESS = of("fairness") - - @JvmField val ROBUSTNESS = of("robustness") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - INTEGRITY, - CONSISTENCY, - PERFORMANCE, - FAIRNESS, - ROBUSTNESS, - } - - enum class Value { - INTEGRITY, - CONSISTENCY, - PERFORMANCE, - FAIRNESS, - ROBUSTNESS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - INTEGRITY -> Value.INTEGRITY - CONSISTENCY -> Value.CONSISTENCY - PERFORMANCE -> Value.PERFORMANCE - FAIRNESS -> Value.FAIRNESS - ROBUSTNESS -> Value.ROBUSTNESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - INTEGRITY -> Known.INTEGRITY - CONSISTENCY -> Known.CONSISTENCY - PERFORMANCE -> Known.PERFORMANCE - FAIRNESS -> Known.FAIRNESS - ROBUSTNESS -> Known.ROBUSTNESS - else -> throw OpenlayerInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CommitTestResultListParams && projectVersionId == other.projectVersionId && includeArchived == other.includeArchived && page == other.page && perPage == other.perPage && status == other.status && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectVersionId, includeArchived, page, perPage, status, type, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "CommitTestResultListParams{projectVersionId=$projectVersionId, includeArchived=$includeArchived, page=$page, perPage=$perPage, status=$status, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitTestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitTestResultListResponse.kt deleted file mode 100644 index 35873592..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitTestResultListResponse.kt +++ /dev/null @@ -1,1363 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openlayer.api.core.BaseDeserializer -import com.openlayer.api.core.BaseSerializer -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.getOrThrow -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = CommitTestResultListResponse.Builder::class) -@NoAutoDetect -class CommitTestResultListResponse -private constructor( - private val items: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun items(): List = items.getRequired("items") - - @JsonProperty("items") @ExcludeMissing fun _items() = items - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): CommitTestResultListResponse = apply { - if (!validated) { - items().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commitTestResultListResponse: CommitTestResultListResponse) = apply { - this.items = commitTestResultListResponse.items - additionalProperties(commitTestResultListResponse.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - @JsonProperty("items") - @ExcludeMissing - fun items(items: JsonField>) = apply { this.items = items } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): CommitTestResultListResponse = - CommitTestResultListResponse( - items.map { it.toImmutable() }, - additionalProperties.toImmutable() - ) - } - - @JsonDeserialize(builder = Item.Builder::class) - @NoAutoDetect - class Item - private constructor( - private val id: JsonField, - private val goal: JsonField, - private val goalId: JsonField, - private val projectVersionId: JsonField, - private val inferencePipelineId: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val dateDataStarts: JsonField, - private val dateDataEnds: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Project version (commit) id. */ - fun id(): String = id.getRequired("id") - - fun goal(): Optional = Optional.ofNullable(goal.getNullable("goal")) - - /** The test id. */ - fun goalId(): Optional = Optional.ofNullable(goalId.getNullable("goalId")) - - /** The project version (commit) id. */ - fun projectVersionId(): Optional = - Optional.ofNullable(projectVersionId.getNullable("projectVersionId")) - - /** The inference pipeline id. */ - fun inferencePipelineId(): Optional = - Optional.ofNullable(inferencePipelineId.getNullable("inferencePipelineId")) - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The data start date. */ - fun dateDataStarts(): Optional = - Optional.ofNullable(dateDataStarts.getNullable("dateDataStarts")) - - /** The data end date. */ - fun dateDataEnds(): Optional = - Optional.ofNullable(dateDataEnds.getNullable("dateDataEnds")) - - /** The status of the test. */ - fun status(): Status = status.getRequired("status") - - /** The status message. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - /** Project version (commit) id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("goal") @ExcludeMissing fun _goal() = goal - - /** The test id. */ - @JsonProperty("goalId") @ExcludeMissing fun _goalId() = goalId - - /** The project version (commit) id. */ - @JsonProperty("projectVersionId") @ExcludeMissing fun _projectVersionId() = projectVersionId - - /** The inference pipeline id. */ - @JsonProperty("inferencePipelineId") - @ExcludeMissing - fun _inferencePipelineId() = inferencePipelineId - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The data start date. */ - @JsonProperty("dateDataStarts") @ExcludeMissing fun _dateDataStarts() = dateDataStarts - - /** The data end date. */ - @JsonProperty("dateDataEnds") @ExcludeMissing fun _dateDataEnds() = dateDataEnds - - /** The status of the test. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The status message. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Item = apply { - if (!validated) { - id() - goal().map { it.validate() } - goalId() - projectVersionId() - inferencePipelineId() - dateCreated() - dateUpdated() - dateDataStarts() - dateDataEnds() - status() - statusMessage() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var goal: JsonField = JsonMissing.of() - private var goalId: JsonField = JsonMissing.of() - private var projectVersionId: JsonField = JsonMissing.of() - private var inferencePipelineId: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var dateDataStarts: JsonField = JsonMissing.of() - private var dateDataEnds: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - this.id = item.id - this.goal = item.goal - this.goalId = item.goalId - this.projectVersionId = item.projectVersionId - this.inferencePipelineId = item.inferencePipelineId - this.dateCreated = item.dateCreated - this.dateUpdated = item.dateUpdated - this.dateDataStarts = item.dateDataStarts - this.dateDataEnds = item.dateDataEnds - this.status = item.status - this.statusMessage = item.statusMessage - additionalProperties(item.additionalProperties) - } - - /** Project version (commit) id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** Project version (commit) id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun goal(goal: Goal) = goal(JsonField.of(goal)) - - @JsonProperty("goal") - @ExcludeMissing - fun goal(goal: JsonField) = apply { this.goal = goal } - - /** The test id. */ - fun goalId(goalId: String) = goalId(JsonField.of(goalId)) - - /** The test id. */ - @JsonProperty("goalId") - @ExcludeMissing - fun goalId(goalId: JsonField) = apply { this.goalId = goalId } - - /** The project version (commit) id. */ - fun projectVersionId(projectVersionId: String) = - projectVersionId(JsonField.of(projectVersionId)) - - /** The project version (commit) id. */ - @JsonProperty("projectVersionId") - @ExcludeMissing - fun projectVersionId(projectVersionId: JsonField) = apply { - this.projectVersionId = projectVersionId - } - - /** The inference pipeline id. */ - fun inferencePipelineId(inferencePipelineId: String) = - inferencePipelineId(JsonField.of(inferencePipelineId)) - - /** The inference pipeline id. */ - @JsonProperty("inferencePipelineId") - @ExcludeMissing - fun inferencePipelineId(inferencePipelineId: JsonField) = apply { - this.inferencePipelineId = inferencePipelineId - } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The data start date. */ - fun dateDataStarts(dateDataStarts: OffsetDateTime) = - dateDataStarts(JsonField.of(dateDataStarts)) - - /** The data start date. */ - @JsonProperty("dateDataStarts") - @ExcludeMissing - fun dateDataStarts(dateDataStarts: JsonField) = apply { - this.dateDataStarts = dateDataStarts - } - - /** The data end date. */ - fun dateDataEnds(dateDataEnds: OffsetDateTime) = - dateDataEnds(JsonField.of(dateDataEnds)) - - /** The data end date. */ - @JsonProperty("dateDataEnds") - @ExcludeMissing - fun dateDataEnds(dateDataEnds: JsonField) = apply { - this.dateDataEnds = dateDataEnds - } - - /** The status of the test. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of the test. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The status message. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The status message. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Item = - Item( - id, - goal, - goalId, - projectVersionId, - inferencePipelineId, - dateCreated, - dateUpdated, - dateDataStarts, - dateDataEnds, - status, - statusMessage, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val RUNNING = of("running") - - @JvmField val PASSING = of("passing") - - @JvmField val FAILING = of("failing") - - @JvmField val SKIPPED = of("skipped") - - @JvmField val ERROR = of("error") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - } - - enum class Value { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - RUNNING -> Value.RUNNING - PASSING -> Value.PASSING - FAILING -> Value.FAILING - SKIPPED -> Value.SKIPPED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - RUNNING -> Known.RUNNING - PASSING -> Known.PASSING - FAILING -> Known.FAILING - SKIPPED -> Known.SKIPPED - ERROR -> Known.ERROR - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Goal.Builder::class) - @NoAutoDetect - class Goal - private constructor( - private val id: JsonField, - private val number: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonValue, - private val evaluationWindow: JsonField, - private val delayWindow: JsonField, - private val type: JsonField, - private val subtype: JsonField, - private val creatorId: JsonField, - private val originProjectVersionId: JsonField, - private val thresholds: JsonField>, - private val archived: JsonField, - private val dateArchived: JsonField, - private val suggested: JsonField, - private val commentCount: JsonField, - private val usesMlModel: JsonField, - private val usesValidationDataset: JsonField, - private val usesTrainingDataset: JsonField, - private val usesReferenceDataset: JsonField, - private val usesProductionData: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The test id. */ - fun id(): String = id.getRequired("id") - - /** The test number. */ - fun number(): Long = number.getRequired("number") - - /** The test name. */ - fun name(): String = name.getRequired("name") - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The evaluation window in seconds. Only applies to tests that use production data. */ - fun evaluationWindow(): Optional = - Optional.ofNullable(evaluationWindow.getNullable("evaluationWindow")) - - /** The delay window in seconds. Only applies to tests that use production data. */ - fun delayWindow(): Optional = - Optional.ofNullable(delayWindow.getNullable("delayWindow")) - - /** The test type. */ - fun type(): String = type.getRequired("type") - - /** The test subtype. */ - fun subtype(): String = subtype.getRequired("subtype") - - /** The test creator id. */ - fun creatorId(): Optional = - Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project version (commit) id where the test was created. */ - fun originProjectVersionId(): Optional = - Optional.ofNullable(originProjectVersionId.getNullable("originProjectVersionId")) - - fun thresholds(): List = thresholds.getRequired("thresholds") - - /** Whether the test is archived. */ - fun archived(): Optional = - Optional.ofNullable(archived.getNullable("archived")) - - /** The date the test was archived. */ - fun dateArchived(): Optional = - Optional.ofNullable(dateArchived.getNullable("dateArchived")) - - /** Whether the test is suggested or user-created. */ - fun suggested(): Boolean = suggested.getRequired("suggested") - - /** The number of comments on the test. */ - fun commentCount(): Long = commentCount.getRequired("commentCount") - - /** Whether the test uses an ML model. */ - fun usesMlModel(): Optional = - Optional.ofNullable(usesMlModel.getNullable("usesMlModel")) - - /** Whether the test uses a validation dataset. */ - fun usesValidationDataset(): Optional = - Optional.ofNullable(usesValidationDataset.getNullable("usesValidationDataset")) - - /** Whether the test uses a training dataset. */ - fun usesTrainingDataset(): Optional = - Optional.ofNullable(usesTrainingDataset.getNullable("usesTrainingDataset")) - - /** Whether the test uses a reference dataset (monitoring mode only). */ - fun usesReferenceDataset(): Optional = - Optional.ofNullable(usesReferenceDataset.getNullable("usesReferenceDataset")) - - /** Whether the test uses production data (monitoring mode only). */ - fun usesProductionData(): Optional = - Optional.ofNullable(usesProductionData.getNullable("usesProductionData")) - - /** The test id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The test number. */ - @JsonProperty("number") @ExcludeMissing fun _number() = number - - /** The test name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The test description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The evaluation window in seconds. Only applies to tests that use production data. */ - @JsonProperty("evaluationWindow") - @ExcludeMissing - fun _evaluationWindow() = evaluationWindow - - /** The delay window in seconds. Only applies to tests that use production data. */ - @JsonProperty("delayWindow") @ExcludeMissing fun _delayWindow() = delayWindow - - /** The test type. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - /** The test subtype. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype - - /** The test creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project version (commit) id where the test was created. */ - @JsonProperty("originProjectVersionId") - @ExcludeMissing - fun _originProjectVersionId() = originProjectVersionId - - @JsonProperty("thresholds") @ExcludeMissing fun _thresholds() = thresholds - - /** Whether the test is archived. */ - @JsonProperty("archived") @ExcludeMissing fun _archived() = archived - - /** The date the test was archived. */ - @JsonProperty("dateArchived") @ExcludeMissing fun _dateArchived() = dateArchived - - /** Whether the test is suggested or user-created. */ - @JsonProperty("suggested") @ExcludeMissing fun _suggested() = suggested - - /** The number of comments on the test. */ - @JsonProperty("commentCount") @ExcludeMissing fun _commentCount() = commentCount - - /** Whether the test uses an ML model. */ - @JsonProperty("usesMlModel") @ExcludeMissing fun _usesMlModel() = usesMlModel - - /** Whether the test uses a validation dataset. */ - @JsonProperty("usesValidationDataset") - @ExcludeMissing - fun _usesValidationDataset() = usesValidationDataset - - /** Whether the test uses a training dataset. */ - @JsonProperty("usesTrainingDataset") - @ExcludeMissing - fun _usesTrainingDataset() = usesTrainingDataset - - /** Whether the test uses a reference dataset (monitoring mode only). */ - @JsonProperty("usesReferenceDataset") - @ExcludeMissing - fun _usesReferenceDataset() = usesReferenceDataset - - /** Whether the test uses production data (monitoring mode only). */ - @JsonProperty("usesProductionData") - @ExcludeMissing - fun _usesProductionData() = usesProductionData - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Goal = apply { - if (!validated) { - id() - number() - name() - dateCreated() - dateUpdated() - evaluationWindow() - delayWindow() - type() - subtype() - creatorId() - originProjectVersionId() - thresholds().forEach { it.validate() } - archived() - dateArchived() - suggested() - commentCount() - usesMlModel() - usesValidationDataset() - usesTrainingDataset() - usesReferenceDataset() - usesProductionData() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var number: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonValue = JsonMissing.of() - private var evaluationWindow: JsonField = JsonMissing.of() - private var delayWindow: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var subtype: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var originProjectVersionId: JsonField = JsonMissing.of() - private var thresholds: JsonField> = JsonMissing.of() - private var archived: JsonField = JsonMissing.of() - private var dateArchived: JsonField = JsonMissing.of() - private var suggested: JsonField = JsonMissing.of() - private var commentCount: JsonField = JsonMissing.of() - private var usesMlModel: JsonField = JsonMissing.of() - private var usesValidationDataset: JsonField = JsonMissing.of() - private var usesTrainingDataset: JsonField = JsonMissing.of() - private var usesReferenceDataset: JsonField = JsonMissing.of() - private var usesProductionData: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(goal: Goal) = apply { - this.id = goal.id - this.number = goal.number - this.name = goal.name - this.dateCreated = goal.dateCreated - this.dateUpdated = goal.dateUpdated - this.description = goal.description - this.evaluationWindow = goal.evaluationWindow - this.delayWindow = goal.delayWindow - this.type = goal.type - this.subtype = goal.subtype - this.creatorId = goal.creatorId - this.originProjectVersionId = goal.originProjectVersionId - this.thresholds = goal.thresholds - this.archived = goal.archived - this.dateArchived = goal.dateArchived - this.suggested = goal.suggested - this.commentCount = goal.commentCount - this.usesMlModel = goal.usesMlModel - this.usesValidationDataset = goal.usesValidationDataset - this.usesTrainingDataset = goal.usesTrainingDataset - this.usesReferenceDataset = goal.usesReferenceDataset - this.usesProductionData = goal.usesProductionData - additionalProperties(goal.additionalProperties) - } - - /** The test id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The test id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The test number. */ - fun number(number: Long) = number(JsonField.of(number)) - - /** The test number. */ - @JsonProperty("number") - @ExcludeMissing - fun number(number: JsonField) = apply { this.number = number } - - /** The test name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The test name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = - dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The test description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonValue) = apply { this.description = description } - - /** - * The evaluation window in seconds. Only applies to tests that use production data. - */ - fun evaluationWindow(evaluationWindow: Double) = - evaluationWindow(JsonField.of(evaluationWindow)) - - /** - * The evaluation window in seconds. Only applies to tests that use production data. - */ - @JsonProperty("evaluationWindow") - @ExcludeMissing - fun evaluationWindow(evaluationWindow: JsonField) = apply { - this.evaluationWindow = evaluationWindow - } - - /** The delay window in seconds. Only applies to tests that use production data. */ - fun delayWindow(delayWindow: Double) = delayWindow(JsonField.of(delayWindow)) - - /** The delay window in seconds. Only applies to tests that use production data. */ - @JsonProperty("delayWindow") - @ExcludeMissing - fun delayWindow(delayWindow: JsonField) = apply { - this.delayWindow = delayWindow - } - - /** The test type. */ - fun type(type: String) = type(JsonField.of(type)) - - /** The test type. */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - /** The test subtype. */ - fun subtype(subtype: String) = subtype(JsonField.of(subtype)) - - /** The test subtype. */ - @JsonProperty("subtype") - @ExcludeMissing - fun subtype(subtype: JsonField) = apply { this.subtype = subtype } - - /** The test creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The test creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project version (commit) id where the test was created. */ - fun originProjectVersionId(originProjectVersionId: String) = - originProjectVersionId(JsonField.of(originProjectVersionId)) - - /** The project version (commit) id where the test was created. */ - @JsonProperty("originProjectVersionId") - @ExcludeMissing - fun originProjectVersionId(originProjectVersionId: JsonField) = apply { - this.originProjectVersionId = originProjectVersionId - } - - fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) - - @JsonProperty("thresholds") - @ExcludeMissing - fun thresholds(thresholds: JsonField>) = apply { - this.thresholds = thresholds - } - - /** Whether the test is archived. */ - fun archived(archived: Boolean) = archived(JsonField.of(archived)) - - /** Whether the test is archived. */ - @JsonProperty("archived") - @ExcludeMissing - fun archived(archived: JsonField) = apply { this.archived = archived } - - /** The date the test was archived. */ - fun dateArchived(dateArchived: OffsetDateTime) = - dateArchived(JsonField.of(dateArchived)) - - /** The date the test was archived. */ - @JsonProperty("dateArchived") - @ExcludeMissing - fun dateArchived(dateArchived: JsonField) = apply { - this.dateArchived = dateArchived - } - - /** Whether the test is suggested or user-created. */ - fun suggested(suggested: Boolean) = suggested(JsonField.of(suggested)) - - /** Whether the test is suggested or user-created. */ - @JsonProperty("suggested") - @ExcludeMissing - fun suggested(suggested: JsonField) = apply { this.suggested = suggested } - - /** The number of comments on the test. */ - fun commentCount(commentCount: Long) = commentCount(JsonField.of(commentCount)) - - /** The number of comments on the test. */ - @JsonProperty("commentCount") - @ExcludeMissing - fun commentCount(commentCount: JsonField) = apply { - this.commentCount = commentCount - } - - /** Whether the test uses an ML model. */ - fun usesMlModel(usesMlModel: Boolean) = usesMlModel(JsonField.of(usesMlModel)) - - /** Whether the test uses an ML model. */ - @JsonProperty("usesMlModel") - @ExcludeMissing - fun usesMlModel(usesMlModel: JsonField) = apply { - this.usesMlModel = usesMlModel - } - - /** Whether the test uses a validation dataset. */ - fun usesValidationDataset(usesValidationDataset: Boolean) = - usesValidationDataset(JsonField.of(usesValidationDataset)) - - /** Whether the test uses a validation dataset. */ - @JsonProperty("usesValidationDataset") - @ExcludeMissing - fun usesValidationDataset(usesValidationDataset: JsonField) = apply { - this.usesValidationDataset = usesValidationDataset - } - - /** Whether the test uses a training dataset. */ - fun usesTrainingDataset(usesTrainingDataset: Boolean) = - usesTrainingDataset(JsonField.of(usesTrainingDataset)) - - /** Whether the test uses a training dataset. */ - @JsonProperty("usesTrainingDataset") - @ExcludeMissing - fun usesTrainingDataset(usesTrainingDataset: JsonField) = apply { - this.usesTrainingDataset = usesTrainingDataset - } - - /** Whether the test uses a reference dataset (monitoring mode only). */ - fun usesReferenceDataset(usesReferenceDataset: Boolean) = - usesReferenceDataset(JsonField.of(usesReferenceDataset)) - - /** Whether the test uses a reference dataset (monitoring mode only). */ - @JsonProperty("usesReferenceDataset") - @ExcludeMissing - fun usesReferenceDataset(usesReferenceDataset: JsonField) = apply { - this.usesReferenceDataset = usesReferenceDataset - } - - /** Whether the test uses production data (monitoring mode only). */ - fun usesProductionData(usesProductionData: Boolean) = - usesProductionData(JsonField.of(usesProductionData)) - - /** Whether the test uses production data (monitoring mode only). */ - @JsonProperty("usesProductionData") - @ExcludeMissing - fun usesProductionData(usesProductionData: JsonField) = apply { - this.usesProductionData = usesProductionData - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Goal = - Goal( - id, - number, - name, - dateCreated, - dateUpdated, - description, - evaluationWindow, - delayWindow, - type, - subtype, - creatorId, - originProjectVersionId, - thresholds.map { it.toImmutable() }, - archived, - dateArchived, - suggested, - commentCount, - usesMlModel, - usesValidationDataset, - usesTrainingDataset, - usesReferenceDataset, - usesProductionData, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Threshold.Builder::class) - @NoAutoDetect - class Threshold - private constructor( - private val measurement: JsonField, - private val insightName: JsonField, - private val insightParameters: JsonField>, - private val operator: JsonField, - private val value: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The measurement to be evaluated. */ - fun measurement(): Optional = - Optional.ofNullable(measurement.getNullable("measurement")) - - /** The insight name to be evaluated. */ - fun insightName(): Optional = - Optional.ofNullable(insightName.getNullable("insightName")) - - fun insightParameters(): Optional> = - Optional.ofNullable(insightParameters.getNullable("insightParameters")) - - /** The operator to be used for the evaluation. */ - fun operator(): Optional = - Optional.ofNullable(operator.getNullable("operator")) - - /** The value to be compared. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - /** The measurement to be evaluated. */ - @JsonProperty("measurement") @ExcludeMissing fun _measurement() = measurement - - /** The insight name to be evaluated. */ - @JsonProperty("insightName") @ExcludeMissing fun _insightName() = insightName - - @JsonProperty("insightParameters") - @ExcludeMissing - fun _insightParameters() = insightParameters - - /** The operator to be used for the evaluation. */ - @JsonProperty("operator") @ExcludeMissing fun _operator() = operator - - /** The value to be compared. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Threshold = apply { - if (!validated) { - measurement() - insightName() - insightParameters() - operator() - value() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var measurement: JsonField = JsonMissing.of() - private var insightName: JsonField = JsonMissing.of() - private var insightParameters: JsonField> = JsonMissing.of() - private var operator: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - this.measurement = threshold.measurement - this.insightName = threshold.insightName - this.insightParameters = threshold.insightParameters - this.operator = threshold.operator - this.value = threshold.value - additionalProperties(threshold.additionalProperties) - } - - /** The measurement to be evaluated. */ - fun measurement(measurement: String) = measurement(JsonField.of(measurement)) - - /** The measurement to be evaluated. */ - @JsonProperty("measurement") - @ExcludeMissing - fun measurement(measurement: JsonField) = apply { - this.measurement = measurement - } - - /** The insight name to be evaluated. */ - fun insightName(insightName: String) = insightName(JsonField.of(insightName)) - - /** The insight name to be evaluated. */ - @JsonProperty("insightName") - @ExcludeMissing - fun insightName(insightName: JsonField) = apply { - this.insightName = insightName - } - - fun insightParameters(insightParameters: List) = - insightParameters(JsonField.of(insightParameters)) - - @JsonProperty("insightParameters") - @ExcludeMissing - fun insightParameters(insightParameters: JsonField>) = apply { - this.insightParameters = insightParameters - } - - /** The operator to be used for the evaluation. */ - fun operator(operator: String) = operator(JsonField.of(operator)) - - /** The operator to be used for the evaluation. */ - @JsonProperty("operator") - @ExcludeMissing - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** The value to be compared. */ - fun value(value: Value) = value(JsonField.of(value)) - - /** The value to be compared. */ - @JsonProperty("value") - @ExcludeMissing - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Threshold = - Threshold( - measurement, - insightName, - insightParameters.map { it.toImmutable() }, - operator, - value, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val number: Double? = null, - private val bool: Boolean? = null, - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Value = apply { - if (!validated) { - if ( - number == null && bool == null && string == null && strings == null - ) { - throw OpenlayerInvalidDataException("Unknown Value: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Value && number == other.number && bool == other.bool && string == other.string && strings == other.strings /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(number, bool, string, strings) /* spotless:on */ - - override fun toString(): String = - when { - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - string != null -> "Value{string=$string}" - strings != null -> "Value{strings=$strings}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) - } - - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw OpenlayerInvalidDataException("Unknown Value: $json") - } - } - - class Deserializer : BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Value { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(bool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Value(strings = it, _json = json) - } - - return Value(_json = json) - } - } - - class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && measurement == other.measurement && insightName == other.insightName && insightParameters == other.insightParameters && operator == other.operator && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(measurement, insightName, insightParameters, operator, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{measurement=$measurement, insightName=$insightName, insightParameters=$insightParameters, operator=$operator, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Goal && id == other.id && number == other.number && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && evaluationWindow == other.evaluationWindow && delayWindow == other.delayWindow && type == other.type && subtype == other.subtype && creatorId == other.creatorId && originProjectVersionId == other.originProjectVersionId && thresholds == other.thresholds && archived == other.archived && dateArchived == other.dateArchived && suggested == other.suggested && commentCount == other.commentCount && usesMlModel == other.usesMlModel && usesValidationDataset == other.usesValidationDataset && usesTrainingDataset == other.usesTrainingDataset && usesReferenceDataset == other.usesReferenceDataset && usesProductionData == other.usesProductionData && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, number, name, dateCreated, dateUpdated, description, evaluationWindow, delayWindow, type, subtype, creatorId, originProjectVersionId, thresholds, archived, dateArchived, suggested, commentCount, usesMlModel, usesValidationDataset, usesTrainingDataset, usesReferenceDataset, usesProductionData, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Goal{id=$id, number=$number, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, evaluationWindow=$evaluationWindow, delayWindow=$delayWindow, type=$type, subtype=$subtype, creatorId=$creatorId, originProjectVersionId=$originProjectVersionId, thresholds=$thresholds, archived=$archived, dateArchived=$dateArchived, suggested=$suggested, commentCount=$commentCount, usesMlModel=$usesMlModel, usesValidationDataset=$usesValidationDataset, usesTrainingDataset=$usesTrainingDataset, usesReferenceDataset=$usesReferenceDataset, usesProductionData=$usesProductionData, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && goal == other.goal && goalId == other.goalId && projectVersionId == other.projectVersionId && inferencePipelineId == other.inferencePipelineId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && dateDataStarts == other.dateDataStarts && dateDataEnds == other.dateDataEnds && status == other.status && statusMessage == other.statusMessage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, goal, goalId, projectVersionId, inferencePipelineId, dateCreated, dateUpdated, dateDataStarts, dateDataEnds, status, statusMessage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, goal=$goal, goalId=$goalId, projectVersionId=$projectVersionId, inferencePipelineId=$inferencePipelineId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateDataStarts=$dateDataStarts, dateDataEnds=$dateDataEnds, status=$status, statusMessage=$statusMessage, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CommitTestResultListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CommitTestResultListResponse{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDataStreamParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDataStreamParams.kt deleted file mode 100644 index a24bf98f..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDataStreamParams.kt +++ /dev/null @@ -1,2152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openlayer.api.core.BaseDeserializer -import com.openlayer.api.core.BaseSerializer -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.getOrThrow -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.util.Objects -import java.util.Optional - -class InferencePipelineDataStreamParams -constructor( - private val inferencePipelineId: String, - private val config: Config, - private val rows: List, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun inferencePipelineId(): String = inferencePipelineId - - fun config(): Config = config - - fun rows(): List = rows - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): InferencePipelineDataStreamBody { - return InferencePipelineDataStreamBody( - config, - rows, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> inferencePipelineId - else -> "" - } - } - - @JsonDeserialize(builder = InferencePipelineDataStreamBody.Builder::class) - @NoAutoDetect - class InferencePipelineDataStreamBody - internal constructor( - private val config: Config?, - private val rows: List?, - private val additionalProperties: Map, - ) { - - /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ - @JsonProperty("config") fun config(): Config? = config - - /** A list of inference data points with inputs and outputs */ - @JsonProperty("rows") fun rows(): List? = rows - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var config: Config? = null - private var rows: List? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineDataStreamBody: InferencePipelineDataStreamBody) = - apply { - this.config = inferencePipelineDataStreamBody.config - this.rows = inferencePipelineDataStreamBody.rows - additionalProperties(inferencePipelineDataStreamBody.additionalProperties) - } - - /** - * Configuration for the data stream. Depends on your **Openlayer project task type**. - */ - @JsonProperty("config") fun config(config: Config) = apply { this.config = config } - - /** A list of inference data points with inputs and outputs */ - @JsonProperty("rows") fun rows(rows: List) = apply { this.rows = rows } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineDataStreamBody = - InferencePipelineDataStreamBody( - checkNotNull(config) { "`config` is required but was not set" }, - checkNotNull(rows) { "`rows` is required but was not set" }.toImmutable(), - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineDataStreamBody && config == other.config && rows == other.rows && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(config, rows, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineDataStreamBody{config=$config, rows=$rows, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var inferencePipelineId: String? = null - private var config: Config? = null - private var rows: MutableList = mutableListOf() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineDataStreamParams: InferencePipelineDataStreamParams) = - apply { - inferencePipelineId = inferencePipelineDataStreamParams.inferencePipelineId - config = inferencePipelineDataStreamParams.config - rows = inferencePipelineDataStreamParams.rows.toMutableList() - additionalHeaders = inferencePipelineDataStreamParams.additionalHeaders.toBuilder() - additionalQueryParams = - inferencePipelineDataStreamParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - inferencePipelineDataStreamParams.additionalBodyProperties.toMutableMap() - } - - fun inferencePipelineId(inferencePipelineId: String) = apply { - this.inferencePipelineId = inferencePipelineId - } - - /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ - fun config(config: Config) = apply { this.config = config } - - /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ - fun config(llmData: Config.LlmData) = apply { this.config = Config.ofLlmData(llmData) } - - /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ - fun config(tabularClassificationData: Config.TabularClassificationData) = apply { - this.config = Config.ofTabularClassificationData(tabularClassificationData) - } - - /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ - fun config(tabularRegressionData: Config.TabularRegressionData) = apply { - this.config = Config.ofTabularRegressionData(tabularRegressionData) - } - - /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ - fun config(textClassificationData: Config.TextClassificationData) = apply { - this.config = Config.ofTextClassificationData(textClassificationData) - } - - /** A list of inference data points with inputs and outputs */ - fun rows(rows: List) = apply { - this.rows.clear() - this.rows.addAll(rows) - } - - /** A list of inference data points with inputs and outputs */ - fun addRow(row: Row) = apply { this.rows.add(row) } - - 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) - } - - fun build(): InferencePipelineDataStreamParams = - InferencePipelineDataStreamParams( - checkNotNull(inferencePipelineId) { - "`inferencePipelineId` is required but was not set" - }, - checkNotNull(config) { "`config` is required but was not set" }, - rows.toImmutable(), - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Config.Deserializer::class) - @JsonSerialize(using = Config.Serializer::class) - class Config - private constructor( - private val llmData: LlmData? = null, - private val tabularClassificationData: TabularClassificationData? = null, - private val tabularRegressionData: TabularRegressionData? = null, - private val textClassificationData: TextClassificationData? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun llmData(): Optional = Optional.ofNullable(llmData) - - fun tabularClassificationData(): Optional = - Optional.ofNullable(tabularClassificationData) - - fun tabularRegressionData(): Optional = - Optional.ofNullable(tabularRegressionData) - - fun textClassificationData(): Optional = - Optional.ofNullable(textClassificationData) - - fun isLlmData(): Boolean = llmData != null - - fun isTabularClassificationData(): Boolean = tabularClassificationData != null - - fun isTabularRegressionData(): Boolean = tabularRegressionData != null - - fun isTextClassificationData(): Boolean = textClassificationData != null - - fun asLlmData(): LlmData = llmData.getOrThrow("llmData") - - fun asTabularClassificationData(): TabularClassificationData = - tabularClassificationData.getOrThrow("tabularClassificationData") - - fun asTabularRegressionData(): TabularRegressionData = - tabularRegressionData.getOrThrow("tabularRegressionData") - - fun asTextClassificationData(): TextClassificationData = - textClassificationData.getOrThrow("textClassificationData") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - llmData != null -> visitor.visitLlmData(llmData) - tabularClassificationData != null -> - visitor.visitTabularClassificationData(tabularClassificationData) - tabularRegressionData != null -> - visitor.visitTabularRegressionData(tabularRegressionData) - textClassificationData != null -> - visitor.visitTextClassificationData(textClassificationData) - else -> visitor.unknown(_json) - } - } - - fun validate(): Config = apply { - if (!validated) { - if ( - llmData == null && - tabularClassificationData == null && - tabularRegressionData == null && - textClassificationData == null - ) { - throw OpenlayerInvalidDataException("Unknown Config: $_json") - } - llmData?.validate() - tabularClassificationData?.validate() - tabularRegressionData?.validate() - textClassificationData?.validate() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Config && llmData == other.llmData && tabularClassificationData == other.tabularClassificationData && tabularRegressionData == other.tabularRegressionData && textClassificationData == other.textClassificationData /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(llmData, tabularClassificationData, tabularRegressionData, textClassificationData) /* spotless:on */ - - override fun toString(): String = - when { - llmData != null -> "Config{llmData=$llmData}" - tabularClassificationData != null -> - "Config{tabularClassificationData=$tabularClassificationData}" - tabularRegressionData != null -> - "Config{tabularRegressionData=$tabularRegressionData}" - textClassificationData != null -> - "Config{textClassificationData=$textClassificationData}" - _json != null -> "Config{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Config") - } - - companion object { - - @JvmStatic fun ofLlmData(llmData: LlmData) = Config(llmData = llmData) - - @JvmStatic - fun ofTabularClassificationData(tabularClassificationData: TabularClassificationData) = - Config(tabularClassificationData = tabularClassificationData) - - @JvmStatic - fun ofTabularRegressionData(tabularRegressionData: TabularRegressionData) = - Config(tabularRegressionData = tabularRegressionData) - - @JvmStatic - fun ofTextClassificationData(textClassificationData: TextClassificationData) = - Config(textClassificationData = textClassificationData) - } - - interface Visitor { - - fun visitLlmData(llmData: LlmData): T - - fun visitTabularClassificationData( - tabularClassificationData: TabularClassificationData - ): T - - fun visitTabularRegressionData(tabularRegressionData: TabularRegressionData): T - - fun visitTextClassificationData(textClassificationData: TextClassificationData): T - - fun unknown(json: JsonValue?): T { - throw OpenlayerInvalidDataException("Unknown Config: $json") - } - } - - class Deserializer : BaseDeserializer(Config::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Config { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(llmData = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(tabularClassificationData = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(tabularRegressionData = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(textClassificationData = it, _json = json) - } - - return Config(_json = json) - } - } - - class Serializer : BaseSerializer(Config::class) { - - override fun serialize( - value: Config, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.llmData != null -> generator.writeObject(value.llmData) - value.tabularClassificationData != null -> - generator.writeObject(value.tabularClassificationData) - value.tabularRegressionData != null -> - generator.writeObject(value.tabularRegressionData) - value.textClassificationData != null -> - generator.writeObject(value.textClassificationData) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Config") - } - } - } - - @JsonDeserialize(builder = LlmData.Builder::class) - @NoAutoDetect - class LlmData - private constructor( - private val numOfTokenColumnName: JsonField, - private val contextColumnName: JsonField, - private val costColumnName: JsonField, - private val groundTruthColumnName: JsonField, - private val inferenceIdColumnName: JsonField, - private val inputVariableNames: JsonField>, - private val latencyColumnName: JsonField, - private val metadata: JsonValue, - private val outputColumnName: JsonField, - private val prompt: JsonField>, - private val questionColumnName: JsonField, - private val timestampColumnName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Name of the column with the total number of tokens. */ - fun numOfTokenColumnName(): Optional = - Optional.ofNullable(numOfTokenColumnName.getNullable("numOfTokenColumnName")) - - /** - * Name of the column with the context retrieved. Applies to RAG use cases. Providing - * the context enables RAG-specific metrics. - */ - fun contextColumnName(): Optional = - Optional.ofNullable(contextColumnName.getNullable("contextColumnName")) - - /** Name of the column with the cost associated with each row. */ - fun costColumnName(): Optional = - Optional.ofNullable(costColumnName.getNullable("costColumnName")) - - /** Name of the column with the ground truths. */ - fun groundTruthColumnName(): Optional = - Optional.ofNullable(groundTruthColumnName.getNullable("groundTruthColumnName")) - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - fun inferenceIdColumnName(): Optional = - Optional.ofNullable(inferenceIdColumnName.getNullable("inferenceIdColumnName")) - - /** Array of input variable names. Each input variable should be a dataset column. */ - fun inputVariableNames(): Optional> = - Optional.ofNullable(inputVariableNames.getNullable("inputVariableNames")) - - /** Name of the column with the latencies. */ - fun latencyColumnName(): Optional = - Optional.ofNullable(latencyColumnName.getNullable("latencyColumnName")) - - /** Name of the column with the model outputs. */ - fun outputColumnName(): String = outputColumnName.getRequired("outputColumnName") - - /** Prompt for the LLM. */ - fun prompt(): Optional> = Optional.ofNullable(prompt.getNullable("prompt")) - - /** - * Name of the column with the questions. Applies to RAG use cases. Providing the - * question enables RAG-specific metrics. - */ - fun questionColumnName(): Optional = - Optional.ofNullable(questionColumnName.getNullable("questionColumnName")) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - fun timestampColumnName(): Optional = - Optional.ofNullable(timestampColumnName.getNullable("timestampColumnName")) - - /** Name of the column with the total number of tokens. */ - @JsonProperty("numOfTokenColumnName") - @ExcludeMissing - fun _numOfTokenColumnName() = numOfTokenColumnName - - /** - * Name of the column with the context retrieved. Applies to RAG use cases. Providing - * the context enables RAG-specific metrics. - */ - @JsonProperty("contextColumnName") - @ExcludeMissing - fun _contextColumnName() = contextColumnName - - /** Name of the column with the cost associated with each row. */ - @JsonProperty("costColumnName") @ExcludeMissing fun _costColumnName() = costColumnName - - /** Name of the column with the ground truths. */ - @JsonProperty("groundTruthColumnName") - @ExcludeMissing - fun _groundTruthColumnName() = groundTruthColumnName - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun _inferenceIdColumnName() = inferenceIdColumnName - - /** Array of input variable names. Each input variable should be a dataset column. */ - @JsonProperty("inputVariableNames") - @ExcludeMissing - fun _inputVariableNames() = inputVariableNames - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun _latencyColumnName() = latencyColumnName - - /** Object with metadata. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** Name of the column with the model outputs. */ - @JsonProperty("outputColumnName") - @ExcludeMissing - fun _outputColumnName() = outputColumnName - - /** Prompt for the LLM. */ - @JsonProperty("prompt") @ExcludeMissing fun _prompt() = prompt - - /** - * Name of the column with the questions. Applies to RAG use cases. Providing the - * question enables RAG-specific metrics. - */ - @JsonProperty("questionColumnName") - @ExcludeMissing - fun _questionColumnName() = questionColumnName - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun _timestampColumnName() = timestampColumnName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): LlmData = apply { - if (!validated) { - numOfTokenColumnName() - contextColumnName() - costColumnName() - groundTruthColumnName() - inferenceIdColumnName() - inputVariableNames() - latencyColumnName() - outputColumnName() - prompt().map { it.forEach { it.validate() } } - questionColumnName() - timestampColumnName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var numOfTokenColumnName: JsonField = JsonMissing.of() - private var contextColumnName: JsonField = JsonMissing.of() - private var costColumnName: JsonField = JsonMissing.of() - private var groundTruthColumnName: JsonField = JsonMissing.of() - private var inferenceIdColumnName: JsonField = JsonMissing.of() - private var inputVariableNames: JsonField> = JsonMissing.of() - private var latencyColumnName: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var outputColumnName: JsonField = JsonMissing.of() - private var prompt: JsonField> = JsonMissing.of() - private var questionColumnName: JsonField = JsonMissing.of() - private var timestampColumnName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(llmData: LlmData) = apply { - this.numOfTokenColumnName = llmData.numOfTokenColumnName - this.contextColumnName = llmData.contextColumnName - this.costColumnName = llmData.costColumnName - this.groundTruthColumnName = llmData.groundTruthColumnName - this.inferenceIdColumnName = llmData.inferenceIdColumnName - this.inputVariableNames = llmData.inputVariableNames - this.latencyColumnName = llmData.latencyColumnName - this.metadata = llmData.metadata - this.outputColumnName = llmData.outputColumnName - this.prompt = llmData.prompt - this.questionColumnName = llmData.questionColumnName - this.timestampColumnName = llmData.timestampColumnName - additionalProperties(llmData.additionalProperties) - } - - /** Name of the column with the total number of tokens. */ - fun numOfTokenColumnName(numOfTokenColumnName: String) = - numOfTokenColumnName(JsonField.of(numOfTokenColumnName)) - - /** Name of the column with the total number of tokens. */ - @JsonProperty("numOfTokenColumnName") - @ExcludeMissing - fun numOfTokenColumnName(numOfTokenColumnName: JsonField) = apply { - this.numOfTokenColumnName = numOfTokenColumnName - } - - /** - * Name of the column with the context retrieved. Applies to RAG use cases. - * Providing the context enables RAG-specific metrics. - */ - fun contextColumnName(contextColumnName: String) = - contextColumnName(JsonField.of(contextColumnName)) - - /** - * Name of the column with the context retrieved. Applies to RAG use cases. - * Providing the context enables RAG-specific metrics. - */ - @JsonProperty("contextColumnName") - @ExcludeMissing - fun contextColumnName(contextColumnName: JsonField) = apply { - this.contextColumnName = contextColumnName - } - - /** Name of the column with the cost associated with each row. */ - fun costColumnName(costColumnName: String) = - costColumnName(JsonField.of(costColumnName)) - - /** Name of the column with the cost associated with each row. */ - @JsonProperty("costColumnName") - @ExcludeMissing - fun costColumnName(costColumnName: JsonField) = apply { - this.costColumnName = costColumnName - } - - /** Name of the column with the ground truths. */ - fun groundTruthColumnName(groundTruthColumnName: String) = - groundTruthColumnName(JsonField.of(groundTruthColumnName)) - - /** Name of the column with the ground truths. */ - @JsonProperty("groundTruthColumnName") - @ExcludeMissing - fun groundTruthColumnName(groundTruthColumnName: JsonField) = apply { - this.groundTruthColumnName = groundTruthColumnName - } - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - fun inferenceIdColumnName(inferenceIdColumnName: String) = - inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { - this.inferenceIdColumnName = inferenceIdColumnName - } - - /** - * Array of input variable names. Each input variable should be a dataset column. - */ - fun inputVariableNames(inputVariableNames: List) = - inputVariableNames(JsonField.of(inputVariableNames)) - - /** - * Array of input variable names. Each input variable should be a dataset column. - */ - @JsonProperty("inputVariableNames") - @ExcludeMissing - fun inputVariableNames(inputVariableNames: JsonField>) = apply { - this.inputVariableNames = inputVariableNames - } - - /** Name of the column with the latencies. */ - fun latencyColumnName(latencyColumnName: String) = - latencyColumnName(JsonField.of(latencyColumnName)) - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun latencyColumnName(latencyColumnName: JsonField) = apply { - this.latencyColumnName = latencyColumnName - } - - /** Object with metadata. */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } - - /** Name of the column with the model outputs. */ - fun outputColumnName(outputColumnName: String) = - outputColumnName(JsonField.of(outputColumnName)) - - /** Name of the column with the model outputs. */ - @JsonProperty("outputColumnName") - @ExcludeMissing - fun outputColumnName(outputColumnName: JsonField) = apply { - this.outputColumnName = outputColumnName - } - - /** Prompt for the LLM. */ - fun prompt(prompt: List) = prompt(JsonField.of(prompt)) - - /** Prompt for the LLM. */ - @JsonProperty("prompt") - @ExcludeMissing - fun prompt(prompt: JsonField>) = apply { this.prompt = prompt } - - /** - * Name of the column with the questions. Applies to RAG use cases. Providing the - * question enables RAG-specific metrics. - */ - fun questionColumnName(questionColumnName: String) = - questionColumnName(JsonField.of(questionColumnName)) - - /** - * Name of the column with the questions. Applies to RAG use cases. Providing the - * question enables RAG-specific metrics. - */ - @JsonProperty("questionColumnName") - @ExcludeMissing - fun questionColumnName(questionColumnName: JsonField) = apply { - this.questionColumnName = questionColumnName - } - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - fun timestampColumnName(timestampColumnName: String) = - timestampColumnName(JsonField.of(timestampColumnName)) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun timestampColumnName(timestampColumnName: JsonField) = apply { - this.timestampColumnName = timestampColumnName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): LlmData = - LlmData( - numOfTokenColumnName, - contextColumnName, - costColumnName, - groundTruthColumnName, - inferenceIdColumnName, - inputVariableNames.map { it.toImmutable() }, - latencyColumnName, - metadata, - outputColumnName, - prompt.map { it.toImmutable() }, - questionColumnName, - timestampColumnName, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Prompt.Builder::class) - @NoAutoDetect - class Prompt - private constructor( - private val role: JsonField, - private val content: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Role of the prompt. */ - fun role(): Optional = Optional.ofNullable(role.getNullable("role")) - - /** Content of the prompt. */ - fun content(): Optional = - Optional.ofNullable(content.getNullable("content")) - - /** Role of the prompt. */ - @JsonProperty("role") @ExcludeMissing fun _role() = role - - /** Content of the prompt. */ - @JsonProperty("content") @ExcludeMissing fun _content() = content - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Prompt = apply { - if (!validated) { - role() - content() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var role: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(prompt: Prompt) = apply { - this.role = prompt.role - this.content = prompt.content - additionalProperties(prompt.additionalProperties) - } - - /** Role of the prompt. */ - fun role(role: String) = role(JsonField.of(role)) - - /** Role of the prompt. */ - @JsonProperty("role") - @ExcludeMissing - fun role(role: JsonField) = apply { this.role = role } - - /** Content of the prompt. */ - fun content(content: String) = content(JsonField.of(content)) - - /** Content of the prompt. */ - @JsonProperty("content") - @ExcludeMissing - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Prompt = - Prompt( - role, - content, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Prompt && role == other.role && content == other.content && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(role, content, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Prompt{role=$role, content=$content, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is LlmData && numOfTokenColumnName == other.numOfTokenColumnName && contextColumnName == other.contextColumnName && costColumnName == other.costColumnName && groundTruthColumnName == other.groundTruthColumnName && inferenceIdColumnName == other.inferenceIdColumnName && inputVariableNames == other.inputVariableNames && latencyColumnName == other.latencyColumnName && metadata == other.metadata && outputColumnName == other.outputColumnName && prompt == other.prompt && questionColumnName == other.questionColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(numOfTokenColumnName, contextColumnName, costColumnName, groundTruthColumnName, inferenceIdColumnName, inputVariableNames, latencyColumnName, metadata, outputColumnName, prompt, questionColumnName, timestampColumnName, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LlmData{numOfTokenColumnName=$numOfTokenColumnName, contextColumnName=$contextColumnName, costColumnName=$costColumnName, groundTruthColumnName=$groundTruthColumnName, inferenceIdColumnName=$inferenceIdColumnName, inputVariableNames=$inputVariableNames, latencyColumnName=$latencyColumnName, metadata=$metadata, outputColumnName=$outputColumnName, prompt=$prompt, questionColumnName=$questionColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = TabularClassificationData.Builder::class) - @NoAutoDetect - class TabularClassificationData - private constructor( - private val categoricalFeatureNames: JsonField>, - private val classNames: JsonField>, - private val featureNames: JsonField>, - private val inferenceIdColumnName: JsonField, - private val labelColumnName: JsonField, - private val latencyColumnName: JsonField, - private val metadata: JsonValue, - private val predictionsColumnName: JsonField, - private val predictionScoresColumnName: JsonField, - private val timestampColumnName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Age", "Geography"]. - */ - fun categoricalFeatureNames(): Optional> = - Optional.ofNullable(categoricalFeatureNames.getNullable("categoricalFeatureNames")) - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - fun classNames(): List = classNames.getRequired("classNames") - - /** Array with all input feature names. */ - fun featureNames(): Optional> = - Optional.ofNullable(featureNames.getNullable("featureNames")) - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - fun inferenceIdColumnName(): Optional = - Optional.ofNullable(inferenceIdColumnName.getNullable("inferenceIdColumnName")) - - /** - * Name of the column with the labels. The data in this column must be **zero-indexed - * integers**, matching the list provided in `classNames`. - */ - fun labelColumnName(): Optional = - Optional.ofNullable(labelColumnName.getNullable("labelColumnName")) - - /** Name of the column with the latencies. */ - fun latencyColumnName(): Optional = - Optional.ofNullable(latencyColumnName.getNullable("latencyColumnName")) - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - fun predictionsColumnName(): Optional = - Optional.ofNullable(predictionsColumnName.getNullable("predictionsColumnName")) - - /** - * Name of the column with the model's predictions as **lists of class probabilities**. - */ - fun predictionScoresColumnName(): Optional = - Optional.ofNullable( - predictionScoresColumnName.getNullable("predictionScoresColumnName") - ) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - fun timestampColumnName(): Optional = - Optional.ofNullable(timestampColumnName.getNullable("timestampColumnName")) - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Age", "Geography"]. - */ - @JsonProperty("categoricalFeatureNames") - @ExcludeMissing - fun _categoricalFeatureNames() = categoricalFeatureNames - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - @JsonProperty("classNames") @ExcludeMissing fun _classNames() = classNames - - /** Array with all input feature names. */ - @JsonProperty("featureNames") @ExcludeMissing fun _featureNames() = featureNames - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun _inferenceIdColumnName() = inferenceIdColumnName - - /** - * Name of the column with the labels. The data in this column must be **zero-indexed - * integers**, matching the list provided in `classNames`. - */ - @JsonProperty("labelColumnName") - @ExcludeMissing - fun _labelColumnName() = labelColumnName - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun _latencyColumnName() = latencyColumnName - - /** Object with metadata. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - @JsonProperty("predictionsColumnName") - @ExcludeMissing - fun _predictionsColumnName() = predictionsColumnName - - /** - * Name of the column with the model's predictions as **lists of class probabilities**. - */ - @JsonProperty("predictionScoresColumnName") - @ExcludeMissing - fun _predictionScoresColumnName() = predictionScoresColumnName - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun _timestampColumnName() = timestampColumnName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TabularClassificationData = apply { - if (!validated) { - categoricalFeatureNames() - classNames() - featureNames() - inferenceIdColumnName() - labelColumnName() - latencyColumnName() - predictionsColumnName() - predictionScoresColumnName() - timestampColumnName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var categoricalFeatureNames: JsonField> = JsonMissing.of() - private var classNames: JsonField> = JsonMissing.of() - private var featureNames: JsonField> = JsonMissing.of() - private var inferenceIdColumnName: JsonField = JsonMissing.of() - private var labelColumnName: JsonField = JsonMissing.of() - private var latencyColumnName: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var predictionsColumnName: JsonField = JsonMissing.of() - private var predictionScoresColumnName: JsonField = JsonMissing.of() - private var timestampColumnName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tabularClassificationData: TabularClassificationData) = apply { - this.categoricalFeatureNames = tabularClassificationData.categoricalFeatureNames - this.classNames = tabularClassificationData.classNames - this.featureNames = tabularClassificationData.featureNames - this.inferenceIdColumnName = tabularClassificationData.inferenceIdColumnName - this.labelColumnName = tabularClassificationData.labelColumnName - this.latencyColumnName = tabularClassificationData.latencyColumnName - this.metadata = tabularClassificationData.metadata - this.predictionsColumnName = tabularClassificationData.predictionsColumnName - this.predictionScoresColumnName = - tabularClassificationData.predictionScoresColumnName - this.timestampColumnName = tabularClassificationData.timestampColumnName - additionalProperties(tabularClassificationData.additionalProperties) - } - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Age", "Geography"]. - */ - fun categoricalFeatureNames(categoricalFeatureNames: List) = - categoricalFeatureNames(JsonField.of(categoricalFeatureNames)) - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Age", "Geography"]. - */ - @JsonProperty("categoricalFeatureNames") - @ExcludeMissing - fun categoricalFeatureNames(categoricalFeatureNames: JsonField>) = - apply { - this.categoricalFeatureNames = categoricalFeatureNames - } - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - fun classNames(classNames: List) = classNames(JsonField.of(classNames)) - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - @JsonProperty("classNames") - @ExcludeMissing - fun classNames(classNames: JsonField>) = apply { - this.classNames = classNames - } - - /** Array with all input feature names. */ - fun featureNames(featureNames: List) = - featureNames(JsonField.of(featureNames)) - - /** Array with all input feature names. */ - @JsonProperty("featureNames") - @ExcludeMissing - fun featureNames(featureNames: JsonField>) = apply { - this.featureNames = featureNames - } - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - fun inferenceIdColumnName(inferenceIdColumnName: String) = - inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { - this.inferenceIdColumnName = inferenceIdColumnName - } - - /** - * Name of the column with the labels. The data in this column must be - * **zero-indexed integers**, matching the list provided in `classNames`. - */ - fun labelColumnName(labelColumnName: String) = - labelColumnName(JsonField.of(labelColumnName)) - - /** - * Name of the column with the labels. The data in this column must be - * **zero-indexed integers**, matching the list provided in `classNames`. - */ - @JsonProperty("labelColumnName") - @ExcludeMissing - fun labelColumnName(labelColumnName: JsonField) = apply { - this.labelColumnName = labelColumnName - } - - /** Name of the column with the latencies. */ - fun latencyColumnName(latencyColumnName: String) = - latencyColumnName(JsonField.of(latencyColumnName)) - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun latencyColumnName(latencyColumnName: JsonField) = apply { - this.latencyColumnName = latencyColumnName - } - - /** Object with metadata. */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - fun predictionsColumnName(predictionsColumnName: String) = - predictionsColumnName(JsonField.of(predictionsColumnName)) - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - @JsonProperty("predictionsColumnName") - @ExcludeMissing - fun predictionsColumnName(predictionsColumnName: JsonField) = apply { - this.predictionsColumnName = predictionsColumnName - } - - /** - * Name of the column with the model's predictions as **lists of class - * probabilities**. - */ - fun predictionScoresColumnName(predictionScoresColumnName: String) = - predictionScoresColumnName(JsonField.of(predictionScoresColumnName)) - - /** - * Name of the column with the model's predictions as **lists of class - * probabilities**. - */ - @JsonProperty("predictionScoresColumnName") - @ExcludeMissing - fun predictionScoresColumnName(predictionScoresColumnName: JsonField) = - apply { - this.predictionScoresColumnName = predictionScoresColumnName - } - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - fun timestampColumnName(timestampColumnName: String) = - timestampColumnName(JsonField.of(timestampColumnName)) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun timestampColumnName(timestampColumnName: JsonField) = apply { - this.timestampColumnName = timestampColumnName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TabularClassificationData = - TabularClassificationData( - categoricalFeatureNames.map { it.toImmutable() }, - classNames.map { it.toImmutable() }, - featureNames.map { it.toImmutable() }, - inferenceIdColumnName, - labelColumnName, - latencyColumnName, - metadata, - predictionsColumnName, - predictionScoresColumnName, - timestampColumnName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TabularClassificationData && categoricalFeatureNames == other.categoricalFeatureNames && classNames == other.classNames && featureNames == other.featureNames && inferenceIdColumnName == other.inferenceIdColumnName && labelColumnName == other.labelColumnName && latencyColumnName == other.latencyColumnName && metadata == other.metadata && predictionsColumnName == other.predictionsColumnName && predictionScoresColumnName == other.predictionScoresColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(categoricalFeatureNames, classNames, featureNames, inferenceIdColumnName, labelColumnName, latencyColumnName, metadata, predictionsColumnName, predictionScoresColumnName, timestampColumnName, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TabularClassificationData{categoricalFeatureNames=$categoricalFeatureNames, classNames=$classNames, featureNames=$featureNames, inferenceIdColumnName=$inferenceIdColumnName, labelColumnName=$labelColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, predictionScoresColumnName=$predictionScoresColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = TabularRegressionData.Builder::class) - @NoAutoDetect - class TabularRegressionData - private constructor( - private val categoricalFeatureNames: JsonField>, - private val featureNames: JsonField>, - private val inferenceIdColumnName: JsonField, - private val latencyColumnName: JsonField, - private val metadata: JsonValue, - private val predictionsColumnName: JsonField, - private val targetColumnName: JsonField, - private val timestampColumnName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Gender", "Geography"]. - */ - fun categoricalFeatureNames(): Optional> = - Optional.ofNullable(categoricalFeatureNames.getNullable("categoricalFeatureNames")) - - /** Array with all input feature names. */ - fun featureNames(): Optional> = - Optional.ofNullable(featureNames.getNullable("featureNames")) - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - fun inferenceIdColumnName(): Optional = - Optional.ofNullable(inferenceIdColumnName.getNullable("inferenceIdColumnName")) - - /** Name of the column with the latencies. */ - fun latencyColumnName(): Optional = - Optional.ofNullable(latencyColumnName.getNullable("latencyColumnName")) - - /** Name of the column with the model's predictions. */ - fun predictionsColumnName(): Optional = - Optional.ofNullable(predictionsColumnName.getNullable("predictionsColumnName")) - - /** Name of the column with the targets (ground truth values). */ - fun targetColumnName(): Optional = - Optional.ofNullable(targetColumnName.getNullable("targetColumnName")) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - fun timestampColumnName(): Optional = - Optional.ofNullable(timestampColumnName.getNullable("timestampColumnName")) - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Gender", "Geography"]. - */ - @JsonProperty("categoricalFeatureNames") - @ExcludeMissing - fun _categoricalFeatureNames() = categoricalFeatureNames - - /** Array with all input feature names. */ - @JsonProperty("featureNames") @ExcludeMissing fun _featureNames() = featureNames - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun _inferenceIdColumnName() = inferenceIdColumnName - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun _latencyColumnName() = latencyColumnName - - /** Object with metadata. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** Name of the column with the model's predictions. */ - @JsonProperty("predictionsColumnName") - @ExcludeMissing - fun _predictionsColumnName() = predictionsColumnName - - /** Name of the column with the targets (ground truth values). */ - @JsonProperty("targetColumnName") - @ExcludeMissing - fun _targetColumnName() = targetColumnName - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun _timestampColumnName() = timestampColumnName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TabularRegressionData = apply { - if (!validated) { - categoricalFeatureNames() - featureNames() - inferenceIdColumnName() - latencyColumnName() - predictionsColumnName() - targetColumnName() - timestampColumnName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var categoricalFeatureNames: JsonField> = JsonMissing.of() - private var featureNames: JsonField> = JsonMissing.of() - private var inferenceIdColumnName: JsonField = JsonMissing.of() - private var latencyColumnName: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var predictionsColumnName: JsonField = JsonMissing.of() - private var targetColumnName: JsonField = JsonMissing.of() - private var timestampColumnName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tabularRegressionData: TabularRegressionData) = apply { - this.categoricalFeatureNames = tabularRegressionData.categoricalFeatureNames - this.featureNames = tabularRegressionData.featureNames - this.inferenceIdColumnName = tabularRegressionData.inferenceIdColumnName - this.latencyColumnName = tabularRegressionData.latencyColumnName - this.metadata = tabularRegressionData.metadata - this.predictionsColumnName = tabularRegressionData.predictionsColumnName - this.targetColumnName = tabularRegressionData.targetColumnName - this.timestampColumnName = tabularRegressionData.timestampColumnName - additionalProperties(tabularRegressionData.additionalProperties) - } - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Gender", "Geography"]. - */ - fun categoricalFeatureNames(categoricalFeatureNames: List) = - categoricalFeatureNames(JsonField.of(categoricalFeatureNames)) - - /** - * Array with the names of all categorical features in the dataset. E.g. - * ["Gender", "Geography"]. - */ - @JsonProperty("categoricalFeatureNames") - @ExcludeMissing - fun categoricalFeatureNames(categoricalFeatureNames: JsonField>) = - apply { - this.categoricalFeatureNames = categoricalFeatureNames - } - - /** Array with all input feature names. */ - fun featureNames(featureNames: List) = - featureNames(JsonField.of(featureNames)) - - /** Array with all input feature names. */ - @JsonProperty("featureNames") - @ExcludeMissing - fun featureNames(featureNames: JsonField>) = apply { - this.featureNames = featureNames - } - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - fun inferenceIdColumnName(inferenceIdColumnName: String) = - inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { - this.inferenceIdColumnName = inferenceIdColumnName - } - - /** Name of the column with the latencies. */ - fun latencyColumnName(latencyColumnName: String) = - latencyColumnName(JsonField.of(latencyColumnName)) - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun latencyColumnName(latencyColumnName: JsonField) = apply { - this.latencyColumnName = latencyColumnName - } - - /** Object with metadata. */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } - - /** Name of the column with the model's predictions. */ - fun predictionsColumnName(predictionsColumnName: String) = - predictionsColumnName(JsonField.of(predictionsColumnName)) - - /** Name of the column with the model's predictions. */ - @JsonProperty("predictionsColumnName") - @ExcludeMissing - fun predictionsColumnName(predictionsColumnName: JsonField) = apply { - this.predictionsColumnName = predictionsColumnName - } - - /** Name of the column with the targets (ground truth values). */ - fun targetColumnName(targetColumnName: String) = - targetColumnName(JsonField.of(targetColumnName)) - - /** Name of the column with the targets (ground truth values). */ - @JsonProperty("targetColumnName") - @ExcludeMissing - fun targetColumnName(targetColumnName: JsonField) = apply { - this.targetColumnName = targetColumnName - } - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - fun timestampColumnName(timestampColumnName: String) = - timestampColumnName(JsonField.of(timestampColumnName)) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun timestampColumnName(timestampColumnName: JsonField) = apply { - this.timestampColumnName = timestampColumnName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TabularRegressionData = - TabularRegressionData( - categoricalFeatureNames.map { it.toImmutable() }, - featureNames.map { it.toImmutable() }, - inferenceIdColumnName, - latencyColumnName, - metadata, - predictionsColumnName, - targetColumnName, - timestampColumnName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TabularRegressionData && categoricalFeatureNames == other.categoricalFeatureNames && featureNames == other.featureNames && inferenceIdColumnName == other.inferenceIdColumnName && latencyColumnName == other.latencyColumnName && metadata == other.metadata && predictionsColumnName == other.predictionsColumnName && targetColumnName == other.targetColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(categoricalFeatureNames, featureNames, inferenceIdColumnName, latencyColumnName, metadata, predictionsColumnName, targetColumnName, timestampColumnName, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TabularRegressionData{categoricalFeatureNames=$categoricalFeatureNames, featureNames=$featureNames, inferenceIdColumnName=$inferenceIdColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, targetColumnName=$targetColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = TextClassificationData.Builder::class) - @NoAutoDetect - class TextClassificationData - private constructor( - private val classNames: JsonField>, - private val inferenceIdColumnName: JsonField, - private val labelColumnName: JsonField, - private val latencyColumnName: JsonField, - private val metadata: JsonValue, - private val predictionsColumnName: JsonField, - private val predictionScoresColumnName: JsonField, - private val textColumnName: JsonField, - private val timestampColumnName: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - fun classNames(): List = classNames.getRequired("classNames") - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - fun inferenceIdColumnName(): Optional = - Optional.ofNullable(inferenceIdColumnName.getNullable("inferenceIdColumnName")) - - /** - * Name of the column with the labels. The data in this column must be **zero-indexed - * integers**, matching the list provided in `classNames`. - */ - fun labelColumnName(): Optional = - Optional.ofNullable(labelColumnName.getNullable("labelColumnName")) - - /** Name of the column with the latencies. */ - fun latencyColumnName(): Optional = - Optional.ofNullable(latencyColumnName.getNullable("latencyColumnName")) - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - fun predictionsColumnName(): Optional = - Optional.ofNullable(predictionsColumnName.getNullable("predictionsColumnName")) - - /** - * Name of the column with the model's predictions as **lists of class probabilities**. - */ - fun predictionScoresColumnName(): Optional = - Optional.ofNullable( - predictionScoresColumnName.getNullable("predictionScoresColumnName") - ) - - /** Name of the column with the text data. */ - fun textColumnName(): Optional = - Optional.ofNullable(textColumnName.getNullable("textColumnName")) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - fun timestampColumnName(): Optional = - Optional.ofNullable(timestampColumnName.getNullable("timestampColumnName")) - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - @JsonProperty("classNames") @ExcludeMissing fun _classNames() = classNames - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun _inferenceIdColumnName() = inferenceIdColumnName - - /** - * Name of the column with the labels. The data in this column must be **zero-indexed - * integers**, matching the list provided in `classNames`. - */ - @JsonProperty("labelColumnName") - @ExcludeMissing - fun _labelColumnName() = labelColumnName - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun _latencyColumnName() = latencyColumnName - - /** Object with metadata. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - @JsonProperty("predictionsColumnName") - @ExcludeMissing - fun _predictionsColumnName() = predictionsColumnName - - /** - * Name of the column with the model's predictions as **lists of class probabilities**. - */ - @JsonProperty("predictionScoresColumnName") - @ExcludeMissing - fun _predictionScoresColumnName() = predictionScoresColumnName - - /** Name of the column with the text data. */ - @JsonProperty("textColumnName") @ExcludeMissing fun _textColumnName() = textColumnName - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun _timestampColumnName() = timestampColumnName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): TextClassificationData = apply { - if (!validated) { - classNames() - inferenceIdColumnName() - labelColumnName() - latencyColumnName() - predictionsColumnName() - predictionScoresColumnName() - textColumnName() - timestampColumnName() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var classNames: JsonField> = JsonMissing.of() - private var inferenceIdColumnName: JsonField = JsonMissing.of() - private var labelColumnName: JsonField = JsonMissing.of() - private var latencyColumnName: JsonField = JsonMissing.of() - private var metadata: JsonValue = JsonMissing.of() - private var predictionsColumnName: JsonField = JsonMissing.of() - private var predictionScoresColumnName: JsonField = JsonMissing.of() - private var textColumnName: JsonField = JsonMissing.of() - private var timestampColumnName: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(textClassificationData: TextClassificationData) = apply { - this.classNames = textClassificationData.classNames - this.inferenceIdColumnName = textClassificationData.inferenceIdColumnName - this.labelColumnName = textClassificationData.labelColumnName - this.latencyColumnName = textClassificationData.latencyColumnName - this.metadata = textClassificationData.metadata - this.predictionsColumnName = textClassificationData.predictionsColumnName - this.predictionScoresColumnName = - textClassificationData.predictionScoresColumnName - this.textColumnName = textClassificationData.textColumnName - this.timestampColumnName = textClassificationData.timestampColumnName - additionalProperties(textClassificationData.additionalProperties) - } - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - fun classNames(classNames: List) = classNames(JsonField.of(classNames)) - - /** - * List of class names indexed by label integer in the dataset. E.g. - * ["Retained", "Exited"] when 0, 1 are in your label column. - */ - @JsonProperty("classNames") - @ExcludeMissing - fun classNames(classNames: JsonField>) = apply { - this.classNames = classNames - } - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - fun inferenceIdColumnName(inferenceIdColumnName: String) = - inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) - - /** - * Name of the column with the inference ids. This is useful if you want to update - * rows at a later point in time. If not provided, a unique id is generated by - * Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - @ExcludeMissing - fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { - this.inferenceIdColumnName = inferenceIdColumnName - } - - /** - * Name of the column with the labels. The data in this column must be - * **zero-indexed integers**, matching the list provided in `classNames`. - */ - fun labelColumnName(labelColumnName: String) = - labelColumnName(JsonField.of(labelColumnName)) - - /** - * Name of the column with the labels. The data in this column must be - * **zero-indexed integers**, matching the list provided in `classNames`. - */ - @JsonProperty("labelColumnName") - @ExcludeMissing - fun labelColumnName(labelColumnName: JsonField) = apply { - this.labelColumnName = labelColumnName - } - - /** Name of the column with the latencies. */ - fun latencyColumnName(latencyColumnName: String) = - latencyColumnName(JsonField.of(latencyColumnName)) - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - @ExcludeMissing - fun latencyColumnName(latencyColumnName: JsonField) = apply { - this.latencyColumnName = latencyColumnName - } - - /** Object with metadata. */ - @JsonProperty("metadata") - @ExcludeMissing - fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - fun predictionsColumnName(predictionsColumnName: String) = - predictionsColumnName(JsonField.of(predictionsColumnName)) - - /** Name of the column with the model's predictions as **zero-indexed integers**. */ - @JsonProperty("predictionsColumnName") - @ExcludeMissing - fun predictionsColumnName(predictionsColumnName: JsonField) = apply { - this.predictionsColumnName = predictionsColumnName - } - - /** - * Name of the column with the model's predictions as **lists of class - * probabilities**. - */ - fun predictionScoresColumnName(predictionScoresColumnName: String) = - predictionScoresColumnName(JsonField.of(predictionScoresColumnName)) - - /** - * Name of the column with the model's predictions as **lists of class - * probabilities**. - */ - @JsonProperty("predictionScoresColumnName") - @ExcludeMissing - fun predictionScoresColumnName(predictionScoresColumnName: JsonField) = - apply { - this.predictionScoresColumnName = predictionScoresColumnName - } - - /** Name of the column with the text data. */ - fun textColumnName(textColumnName: String) = - textColumnName(JsonField.of(textColumnName)) - - /** Name of the column with the text data. */ - @JsonProperty("textColumnName") - @ExcludeMissing - fun textColumnName(textColumnName: JsonField) = apply { - this.textColumnName = textColumnName - } - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - fun timestampColumnName(timestampColumnName: String) = - timestampColumnName(JsonField.of(timestampColumnName)) - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If - * not provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - @ExcludeMissing - fun timestampColumnName(timestampColumnName: JsonField) = apply { - this.timestampColumnName = timestampColumnName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): TextClassificationData = - TextClassificationData( - classNames.map { it.toImmutable() }, - inferenceIdColumnName, - labelColumnName, - latencyColumnName, - metadata, - predictionsColumnName, - predictionScoresColumnName, - textColumnName, - timestampColumnName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TextClassificationData && classNames == other.classNames && inferenceIdColumnName == other.inferenceIdColumnName && labelColumnName == other.labelColumnName && latencyColumnName == other.latencyColumnName && metadata == other.metadata && predictionsColumnName == other.predictionsColumnName && predictionScoresColumnName == other.predictionScoresColumnName && textColumnName == other.textColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(classNames, inferenceIdColumnName, labelColumnName, latencyColumnName, metadata, predictionsColumnName, predictionScoresColumnName, textColumnName, timestampColumnName, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TextClassificationData{classNames=$classNames, inferenceIdColumnName=$inferenceIdColumnName, labelColumnName=$labelColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, predictionScoresColumnName=$predictionScoresColumnName, textColumnName=$textColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" - } - } - - @JsonDeserialize(builder = Row.Builder::class) - @NoAutoDetect - class Row - private constructor( - private val additionalProperties: Map, - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(row: Row) = apply { additionalProperties(row.additionalProperties) } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Row = Row(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Row && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Row{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineDataStreamParams && inferencePipelineId == other.inferencePipelineId && config == other.config && rows == other.rows && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, config, rows, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "InferencePipelineDataStreamParams{inferencePipelineId=$inferencePipelineId, config=$config, rows=$rows, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDataStreamResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDataStreamResponse.kt deleted file mode 100644 index 4f6cbe7b..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDataStreamResponse.kt +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.util.Objects - -@JsonDeserialize(builder = InferencePipelineDataStreamResponse.Builder::class) -@NoAutoDetect -class InferencePipelineDataStreamResponse -private constructor( - private val success: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun success(): Success = success.getRequired("success") - - @JsonProperty("success") @ExcludeMissing fun _success() = success - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InferencePipelineDataStreamResponse = apply { - if (!validated) { - success() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var success: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - inferencePipelineDataStreamResponse: InferencePipelineDataStreamResponse - ) = apply { - this.success = inferencePipelineDataStreamResponse.success - additionalProperties(inferencePipelineDataStreamResponse.additionalProperties) - } - - fun success(success: Success) = success(JsonField.of(success)) - - @JsonProperty("success") - @ExcludeMissing - fun success(success: JsonField) = apply { this.success = success } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineDataStreamResponse = - InferencePipelineDataStreamResponse(success, additionalProperties.toImmutable()) - } - - class Success - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TRUE = of(true) - - @JvmStatic fun of(value: Boolean) = Success(JsonField.of(value)) - } - - enum class Known { - TRUE, - } - - enum class Value { - TRUE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TRUE -> Value.TRUE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TRUE -> Known.TRUE - else -> throw OpenlayerInvalidDataException("Unknown Success: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Success && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineDataStreamResponse && success == other.success && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineDataStreamResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRetrieveResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRetrieveResponse.kt deleted file mode 100644 index 3dd305e3..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRetrieveResponse.kt +++ /dev/null @@ -1,2068 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InferencePipelineRetrieveResponse.Builder::class) -@NoAutoDetect -class InferencePipelineRetrieveResponse -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val workspaceId: JsonField, - private val project: JsonField, - private val workspace: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val dateLastSampleReceived: JsonField, - private val description: JsonField, - private val dateLastEvaluated: JsonField, - private val dateOfNextEvaluation: JsonField, - private val passingGoalCount: JsonField, - private val failingGoalCount: JsonField, - private val totalGoalCount: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val links: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The inference pipeline id. */ - fun id(): String = id.getRequired("id") - - /** The project id. */ - fun projectId(): String = projectId.getRequired("projectId") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - fun project(): Optional = Optional.ofNullable(project.getNullable("project")) - - fun workspace(): Optional = Optional.ofNullable(workspace.getNullable("workspace")) - - /** The inference pipeline name. */ - fun name(): String = name.getRequired("name") - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The last data sample received date. */ - fun dateLastSampleReceived(): Optional = - Optional.ofNullable(dateLastSampleReceived.getNullable("dateLastSampleReceived")) - - /** The inference pipeline description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The last test evaluation date. */ - fun dateLastEvaluated(): Optional = - Optional.ofNullable(dateLastEvaluated.getNullable("dateLastEvaluated")) - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(): Optional = - Optional.ofNullable(dateOfNextEvaluation.getNullable("dateOfNextEvaluation")) - - /** The number of tests passing. */ - fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") - - /** The number of tests failing. */ - fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") - - /** The total number of tests. */ - fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") - - /** The status of test evaluation for the inference pipeline. */ - fun status(): Status = status.getRequired("status") - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - fun links(): Links = links.getRequired("links") - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The project id. */ - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - @JsonProperty("project") @ExcludeMissing fun _project() = project - - @JsonProperty("workspace") @ExcludeMissing fun _workspace() = workspace - - /** The inference pipeline name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun _dateLastSampleReceived() = dateLastSampleReceived - - /** The inference pipeline description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") @ExcludeMissing fun _dateLastEvaluated() = dateLastEvaluated - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun _dateOfNextEvaluation() = dateOfNextEvaluation - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InferencePipelineRetrieveResponse = apply { - if (!validated) { - id() - projectId() - workspaceId() - project().map { it.validate() } - workspace().map { it.validate() } - name() - dateCreated() - dateUpdated() - dateLastSampleReceived() - description() - dateLastEvaluated() - dateOfNextEvaluation() - passingGoalCount() - failingGoalCount() - totalGoalCount() - status() - statusMessage() - links().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var project: JsonField = JsonMissing.of() - private var workspace: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var dateLastSampleReceived: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dateLastEvaluated: JsonField = JsonMissing.of() - private var dateOfNextEvaluation: JsonField = JsonMissing.of() - private var passingGoalCount: JsonField = JsonMissing.of() - private var failingGoalCount: JsonField = JsonMissing.of() - private var totalGoalCount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineRetrieveResponse: InferencePipelineRetrieveResponse) = - apply { - this.id = inferencePipelineRetrieveResponse.id - this.projectId = inferencePipelineRetrieveResponse.projectId - this.workspaceId = inferencePipelineRetrieveResponse.workspaceId - this.project = inferencePipelineRetrieveResponse.project - this.workspace = inferencePipelineRetrieveResponse.workspace - this.name = inferencePipelineRetrieveResponse.name - this.dateCreated = inferencePipelineRetrieveResponse.dateCreated - this.dateUpdated = inferencePipelineRetrieveResponse.dateUpdated - this.dateLastSampleReceived = - inferencePipelineRetrieveResponse.dateLastSampleReceived - this.description = inferencePipelineRetrieveResponse.description - this.dateLastEvaluated = inferencePipelineRetrieveResponse.dateLastEvaluated - this.dateOfNextEvaluation = inferencePipelineRetrieveResponse.dateOfNextEvaluation - this.passingGoalCount = inferencePipelineRetrieveResponse.passingGoalCount - this.failingGoalCount = inferencePipelineRetrieveResponse.failingGoalCount - this.totalGoalCount = inferencePipelineRetrieveResponse.totalGoalCount - this.status = inferencePipelineRetrieveResponse.status - this.statusMessage = inferencePipelineRetrieveResponse.statusMessage - this.links = inferencePipelineRetrieveResponse.links - additionalProperties(inferencePipelineRetrieveResponse.additionalProperties) - } - - /** The inference pipeline id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The project id. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** The project id. */ - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } - - fun project(project: Project) = project(JsonField.of(project)) - - @JsonProperty("project") - @ExcludeMissing - fun project(project: JsonField) = apply { this.project = project } - - fun workspace(workspace: Workspace) = workspace(JsonField.of(workspace)) - - @JsonProperty("workspace") - @ExcludeMissing - fun workspace(workspace: JsonField) = apply { this.workspace = workspace } - - /** The inference pipeline name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The inference pipeline name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The last data sample received date. */ - fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime) = - dateLastSampleReceived(JsonField.of(dateLastSampleReceived)) - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { - this.dateLastSampleReceived = dateLastSampleReceived - } - - /** The inference pipeline description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The inference pipeline description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The last test evaluation date. */ - fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime) = - dateLastEvaluated(JsonField.of(dateLastEvaluated)) - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") - @ExcludeMissing - fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { - this.dateLastEvaluated = dateLastEvaluated - } - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime) = - dateOfNextEvaluation(JsonField.of(dateOfNextEvaluation)) - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { - this.dateOfNextEvaluation = dateOfNextEvaluation - } - - /** The number of tests passing. */ - fun passingGoalCount(passingGoalCount: Long) = - passingGoalCount(JsonField.of(passingGoalCount)) - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") - @ExcludeMissing - fun passingGoalCount(passingGoalCount: JsonField) = apply { - this.passingGoalCount = passingGoalCount - } - - /** The number of tests failing. */ - fun failingGoalCount(failingGoalCount: Long) = - failingGoalCount(JsonField.of(failingGoalCount)) - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") - @ExcludeMissing - fun failingGoalCount(failingGoalCount: JsonField) = apply { - this.failingGoalCount = failingGoalCount - } - - /** The total number of tests. */ - fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") - @ExcludeMissing - fun totalGoalCount(totalGoalCount: JsonField) = apply { - this.totalGoalCount = totalGoalCount - } - - /** The status of test evaluation for the inference pipeline. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - fun links(links: Links) = links(JsonField.of(links)) - - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineRetrieveResponse = - InferencePipelineRetrieveResponse( - id, - projectId, - workspaceId, - project, - workspace, - name, - dateCreated, - dateUpdated, - dateLastSampleReceived, - description, - dateLastEvaluated, - dateOfNextEvaluation, - passingGoalCount, - failingGoalCount, - totalGoalCount, - status, - statusMessage, - links, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Project.Builder::class) - @NoAutoDetect - class Project - private constructor( - private val id: JsonField, - private val workspaceId: JsonField, - private val creatorId: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonField, - private val source: JsonField, - private val taskType: JsonField, - private val versionCount: JsonField, - private val inferencePipelineCount: JsonField, - private val goalCount: JsonField, - private val developmentGoalCount: JsonField, - private val monitoringGoalCount: JsonField, - private val links: JsonField, - private val gitRepo: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The project id. */ - fun id(): String = id.getRequired("id") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - /** The project creator id. */ - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project name. */ - fun name(): String = name.getRequired("name") - - /** The project creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The project last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The project description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The source of the project. */ - fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - - /** The task type of the project. */ - fun taskType(): TaskType = taskType.getRequired("taskType") - - /** The number of versions (commits) in the project. */ - fun versionCount(): Long = versionCount.getRequired("versionCount") - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(): Long = - inferencePipelineCount.getRequired("inferencePipelineCount") - - /** The total number of tests in the project. */ - fun goalCount(): Long = goalCount.getRequired("goalCount") - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") - - /** Links to the project. */ - fun links(): Links = links.getRequired("links") - - fun gitRepo(): Optional = Optional.ofNullable(gitRepo.getNullable("gitRepo")) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The project creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The project description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The source of the project. */ - @JsonProperty("source") @ExcludeMissing fun _source() = source - - /** The task type of the project. */ - @JsonProperty("taskType") @ExcludeMissing fun _taskType() = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") @ExcludeMissing fun _versionCount() = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun _inferencePipelineCount() = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") @ExcludeMissing fun _goalCount() = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun _developmentGoalCount() = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun _monitoringGoalCount() = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo() = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Project = apply { - if (!validated) { - id() - workspaceId() - creatorId() - name() - dateCreated() - dateUpdated() - description() - source() - taskType() - versionCount() - inferencePipelineCount() - goalCount() - developmentGoalCount() - monitoringGoalCount() - links().validate() - gitRepo().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var taskType: JsonField = JsonMissing.of() - private var versionCount: JsonField = JsonMissing.of() - private var inferencePipelineCount: JsonField = JsonMissing.of() - private var goalCount: JsonField = JsonMissing.of() - private var developmentGoalCount: JsonField = JsonMissing.of() - private var monitoringGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var gitRepo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(project: Project) = apply { - this.id = project.id - this.workspaceId = project.workspaceId - this.creatorId = project.creatorId - this.name = project.name - this.dateCreated = project.dateCreated - this.dateUpdated = project.dateUpdated - this.description = project.description - this.source = project.source - this.taskType = project.taskType - this.versionCount = project.versionCount - this.inferencePipelineCount = project.inferencePipelineCount - this.goalCount = project.goalCount - this.developmentGoalCount = project.developmentGoalCount - this.monitoringGoalCount = project.monitoringGoalCount - this.links = project.links - this.gitRepo = project.gitRepo - additionalProperties(project.additionalProperties) - } - - /** The project id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { - this.workspaceId = workspaceId - } - - /** The project creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The project creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The project name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The project creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The project last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The project description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The project description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - /** The source of the project. */ - fun source(source: Source) = source(JsonField.of(source)) - - /** The source of the project. */ - @JsonProperty("source") - @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) - - /** The task type of the project. */ - @JsonProperty("taskType") - @ExcludeMissing - fun taskType(taskType: JsonField) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - @ExcludeMissing - fun versionCount(versionCount: JsonField) = apply { - this.versionCount = versionCount - } - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(inferencePipelineCount: Long) = - inferencePipelineCount(JsonField.of(inferencePipelineCount)) - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - @ExcludeMissing - fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(developmentGoalCount: Long) = - developmentGoalCount(JsonField.of(developmentGoalCount)) - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun developmentGoalCount(developmentGoalCount: JsonField) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(monitoringGoalCount: Long) = - monitoringGoalCount(JsonField.of(monitoringGoalCount)) - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - fun links(links: Links) = links(JsonField.of(links)) - - /** Links to the project. */ - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun gitRepo(gitRepo: GitRepo) = gitRepo(JsonField.of(gitRepo)) - - @JsonProperty("gitRepo") - @ExcludeMissing - fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Project = - Project( - id, - workspaceId, - creatorId, - name, - dateCreated, - dateUpdated, - description, - source, - taskType, - versionCount, - inferencePipelineCount, - goalCount, - developmentGoalCount, - monitoringGoalCount, - links, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: JsonField, - private val gitId: JsonField, - private val dateConnected: JsonField, - private val dateUpdated: JsonField, - private val branch: JsonField, - private val name: JsonField, - private val private_: JsonField, - private val slug: JsonField, - private val url: JsonField, - private val rootDir: JsonField, - private val projectId: JsonField, - private val gitAccountId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun gitId(): Long = gitId.getRequired("gitId") - - fun dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - - fun name(): String = name.getRequired("name") - - fun private_(): Boolean = private_.getRequired("private") - - fun slug(): String = slug.getRequired("slug") - - fun url(): String = url.getRequired("url") - - fun rootDir(): Optional = Optional.ofNullable(rootDir.getNullable("rootDir")) - - fun projectId(): String = projectId.getRequired("projectId") - - fun gitAccountId(): String = gitAccountId.getRequired("gitAccountId") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("gitId") @ExcludeMissing fun _gitId() = gitId - - @JsonProperty("dateConnected") @ExcludeMissing fun _dateConnected() = dateConnected - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("private") @ExcludeMissing fun _private_() = private_ - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("rootDir") @ExcludeMissing fun _rootDir() = rootDir - - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("gitAccountId") @ExcludeMissing fun _gitAccountId() = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitRepo = apply { - if (!validated) { - id() - gitId() - dateConnected() - dateUpdated() - branch() - name() - private_() - slug() - url() - rootDir() - projectId() - gitAccountId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var gitId: JsonField = JsonMissing.of() - private var dateConnected: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var private_: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var rootDir: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var gitAccountId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) - - @JsonProperty("gitId") - @ExcludeMissing - fun gitId(gitId: JsonField) = apply { this.gitId = gitId } - - fun dateConnected(dateConnected: OffsetDateTime) = - dateConnected(JsonField.of(dateConnected)) - - @JsonProperty("dateConnected") - @ExcludeMissing - fun dateConnected(dateConnected: JsonField) = apply { - this.dateConnected = dateConnected - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun branch(branch: String) = branch(JsonField.of(branch)) - - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun private_(private_: Boolean) = private_(JsonField.of(private_)) - - @JsonProperty("private") - @ExcludeMissing - fun private_(private_: JsonField) = apply { this.private_ = private_ } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) - - @JsonProperty("rootDir") - @ExcludeMissing - fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) - - @JsonProperty("gitAccountId") - @ExcludeMissing - fun gitAccountId(gitAccountId: JsonField) = apply { - this.gitAccountId = gitAccountId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - id, - gitId, - dateConnected, - dateUpdated, - branch, - name, - private_, - slug, - url, - rootDir, - projectId, - gitAccountId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Project && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Project{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Workspace.Builder::class) - @NoAutoDetect - class Workspace - private constructor( - private val id: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val creatorId: JsonField, - private val inviteCode: JsonField, - private val wildcardDomains: JsonField>, - private val projectCount: JsonField, - private val memberCount: JsonField, - private val monthlyUsage: JsonField>, - private val inviteCount: JsonField, - private val periodStartDate: JsonField, - private val periodEndDate: JsonField, - private val samlOnlyAccess: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - fun slug(): String = slug.getRequired("slug") - - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - fun inviteCode(): Optional = - Optional.ofNullable(inviteCode.getNullable("inviteCode")) - - fun wildcardDomains(): Optional> = - Optional.ofNullable(wildcardDomains.getNullable("wildcardDomains")) - - fun projectCount(): Long = projectCount.getRequired("projectCount") - - fun memberCount(): Long = memberCount.getRequired("memberCount") - - fun monthlyUsage(): Optional> = - Optional.ofNullable(monthlyUsage.getNullable("monthlyUsage")) - - fun inviteCount(): Long = inviteCount.getRequired("inviteCount") - - fun periodStartDate(): Optional = - Optional.ofNullable(periodStartDate.getNullable("periodStartDate")) - - fun periodEndDate(): Optional = - Optional.ofNullable(periodEndDate.getNullable("periodEndDate")) - - fun samlOnlyAccess(): Optional = - Optional.ofNullable(samlOnlyAccess.getNullable("samlOnlyAccess")) - - fun status(): Status = status.getRequired("status") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - @JsonProperty("inviteCode") @ExcludeMissing fun _inviteCode() = inviteCode - - @JsonProperty("wildcardDomains") @ExcludeMissing fun _wildcardDomains() = wildcardDomains - - @JsonProperty("projectCount") @ExcludeMissing fun _projectCount() = projectCount - - @JsonProperty("memberCount") @ExcludeMissing fun _memberCount() = memberCount - - @JsonProperty("monthlyUsage") @ExcludeMissing fun _monthlyUsage() = monthlyUsage - - @JsonProperty("inviteCount") @ExcludeMissing fun _inviteCount() = inviteCount - - @JsonProperty("periodStartDate") @ExcludeMissing fun _periodStartDate() = periodStartDate - - @JsonProperty("periodEndDate") @ExcludeMissing fun _periodEndDate() = periodEndDate - - @JsonProperty("samlOnlyAccess") @ExcludeMissing fun _samlOnlyAccess() = samlOnlyAccess - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Workspace = apply { - if (!validated) { - id() - name() - slug() - dateCreated() - dateUpdated() - creatorId() - inviteCode() - wildcardDomains() - projectCount() - memberCount() - monthlyUsage().map { it.forEach { it.validate() } } - inviteCount() - periodStartDate() - periodEndDate() - samlOnlyAccess() - status() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var inviteCode: JsonField = JsonMissing.of() - private var wildcardDomains: JsonField> = JsonMissing.of() - private var projectCount: JsonField = JsonMissing.of() - private var memberCount: JsonField = JsonMissing.of() - private var monthlyUsage: JsonField> = JsonMissing.of() - private var inviteCount: JsonField = JsonMissing.of() - private var periodStartDate: JsonField = JsonMissing.of() - private var periodEndDate: JsonField = JsonMissing.of() - private var samlOnlyAccess: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(workspace: Workspace) = apply { - this.id = workspace.id - this.name = workspace.name - this.slug = workspace.slug - this.dateCreated = workspace.dateCreated - this.dateUpdated = workspace.dateUpdated - this.creatorId = workspace.creatorId - this.inviteCode = workspace.inviteCode - this.wildcardDomains = workspace.wildcardDomains - this.projectCount = workspace.projectCount - this.memberCount = workspace.memberCount - this.monthlyUsage = workspace.monthlyUsage - this.inviteCount = workspace.inviteCount - this.periodStartDate = workspace.periodStartDate - this.periodEndDate = workspace.periodEndDate - this.samlOnlyAccess = workspace.samlOnlyAccess - this.status = workspace.status - additionalProperties(workspace.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) - - @JsonProperty("inviteCode") - @ExcludeMissing - fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } - - fun wildcardDomains(wildcardDomains: List) = - wildcardDomains(JsonField.of(wildcardDomains)) - - @JsonProperty("wildcardDomains") - @ExcludeMissing - fun wildcardDomains(wildcardDomains: JsonField>) = apply { - this.wildcardDomains = wildcardDomains - } - - fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) - - @JsonProperty("projectCount") - @ExcludeMissing - fun projectCount(projectCount: JsonField) = apply { - this.projectCount = projectCount - } - - fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) - - @JsonProperty("memberCount") - @ExcludeMissing - fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } - - fun monthlyUsage(monthlyUsage: List) = - monthlyUsage(JsonField.of(monthlyUsage)) - - @JsonProperty("monthlyUsage") - @ExcludeMissing - fun monthlyUsage(monthlyUsage: JsonField>) = apply { - this.monthlyUsage = monthlyUsage - } - - fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) - - @JsonProperty("inviteCount") - @ExcludeMissing - fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } - - fun periodStartDate(periodStartDate: OffsetDateTime) = - periodStartDate(JsonField.of(periodStartDate)) - - @JsonProperty("periodStartDate") - @ExcludeMissing - fun periodStartDate(periodStartDate: JsonField) = apply { - this.periodStartDate = periodStartDate - } - - fun periodEndDate(periodEndDate: OffsetDateTime) = - periodEndDate(JsonField.of(periodEndDate)) - - @JsonProperty("periodEndDate") - @ExcludeMissing - fun periodEndDate(periodEndDate: JsonField) = apply { - this.periodEndDate = periodEndDate - } - - fun samlOnlyAccess(samlOnlyAccess: Boolean) = - samlOnlyAccess(JsonField.of(samlOnlyAccess)) - - @JsonProperty("samlOnlyAccess") - @ExcludeMissing - fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { - this.samlOnlyAccess = samlOnlyAccess - } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Workspace = - Workspace( - id, - name, - slug, - dateCreated, - dateUpdated, - creatorId, - inviteCode, - wildcardDomains.map { it.toImmutable() }, - projectCount, - memberCount, - monthlyUsage.map { it.toImmutable() }, - inviteCount, - periodStartDate, - periodEndDate, - samlOnlyAccess, - status, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val PAST_DUE = of("past_due") - - @JvmField val UNPAID = of("unpaid") - - @JvmField val CANCELED = of("canceled") - - @JvmField val INCOMPLETE = of("incomplete") - - @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") - - @JvmField val TRIALING = of("trialing") - - @JvmField val PAUSED = of("paused") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - } - - enum class Value { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - PAST_DUE -> Value.PAST_DUE - UNPAID -> Value.UNPAID - CANCELED -> Value.CANCELED - INCOMPLETE -> Value.INCOMPLETE - INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED - TRIALING -> Value.TRIALING - PAUSED -> Value.PAUSED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - PAST_DUE -> Known.PAST_DUE - UNPAID -> Known.UNPAID - CANCELED -> Known.CANCELED - INCOMPLETE -> Known.INCOMPLETE - INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED - TRIALING -> Known.TRIALING - PAUSED -> Known.PAUSED - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = MonthlyUsage.Builder::class) - @NoAutoDetect - class MonthlyUsage - private constructor( - private val monthYear: JsonField, - private val predictionCount: JsonField, - private val executionTimeMs: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun monthYear(): Optional = - Optional.ofNullable(monthYear.getNullable("monthYear")) - - fun predictionCount(): Optional = - Optional.ofNullable(predictionCount.getNullable("predictionCount")) - - fun executionTimeMs(): Optional = - Optional.ofNullable(executionTimeMs.getNullable("executionTimeMs")) - - @JsonProperty("monthYear") @ExcludeMissing fun _monthYear() = monthYear - - @JsonProperty("predictionCount") - @ExcludeMissing - fun _predictionCount() = predictionCount - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun _executionTimeMs() = executionTimeMs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MonthlyUsage = apply { - if (!validated) { - monthYear() - predictionCount() - executionTimeMs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var monthYear: JsonField = JsonMissing.of() - private var predictionCount: JsonField = JsonMissing.of() - private var executionTimeMs: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monthlyUsage: MonthlyUsage) = apply { - this.monthYear = monthlyUsage.monthYear - this.predictionCount = monthlyUsage.predictionCount - this.executionTimeMs = monthlyUsage.executionTimeMs - additionalProperties(monthlyUsage.additionalProperties) - } - - fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) - - @JsonProperty("monthYear") - @ExcludeMissing - fun monthYear(monthYear: JsonField) = apply { - this.monthYear = monthYear - } - - fun predictionCount(predictionCount: Long) = - predictionCount(JsonField.of(predictionCount)) - - @JsonProperty("predictionCount") - @ExcludeMissing - fun predictionCount(predictionCount: JsonField) = apply { - this.predictionCount = predictionCount - } - - fun executionTimeMs(executionTimeMs: Long) = - executionTimeMs(JsonField.of(executionTimeMs)) - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun executionTimeMs(executionTimeMs: JsonField) = apply { - this.executionTimeMs = executionTimeMs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MonthlyUsage = - MonthlyUsage( - monthYear, - predictionCount, - executionTimeMs, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonthlyUsage && monthYear == other.monthYear && predictionCount == other.predictionCount && executionTimeMs == other.executionTimeMs && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(monthYear, predictionCount, executionTimeMs, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonthlyUsage{monthYear=$monthYear, predictionCount=$predictionCount, executionTimeMs=$executionTimeMs, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Workspace && id == other.id && name == other.name && slug == other.slug && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && creatorId == other.creatorId && inviteCode == other.inviteCode && wildcardDomains == other.wildcardDomains && projectCount == other.projectCount && memberCount == other.memberCount && monthlyUsage == other.monthlyUsage && inviteCount == other.inviteCount && periodStartDate == other.periodStartDate && periodEndDate == other.periodEndDate && samlOnlyAccess == other.samlOnlyAccess && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, slug, dateCreated, dateUpdated, creatorId, inviteCode, wildcardDomains, projectCount, memberCount, monthlyUsage, inviteCount, periodStartDate, periodEndDate, samlOnlyAccess, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Workspace{id=$id, name=$name, slug=$slug, dateCreated=$dateCreated, dateUpdated=$dateUpdated, creatorId=$creatorId, inviteCode=$inviteCode, wildcardDomains=$wildcardDomains, projectCount=$projectCount, memberCount=$memberCount, monthlyUsage=$monthlyUsage, inviteCount=$inviteCount, periodStartDate=$periodStartDate, periodEndDate=$periodEndDate, samlOnlyAccess=$samlOnlyAccess, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineRetrieveResponse && id == other.id && projectId == other.projectId && workspaceId == other.workspaceId && project == other.project && workspace == other.workspace && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && dateLastSampleReceived == other.dateLastSampleReceived && description == other.description && dateLastEvaluated == other.dateLastEvaluated && dateOfNextEvaluation == other.dateOfNextEvaluation && passingGoalCount == other.passingGoalCount && failingGoalCount == other.failingGoalCount && totalGoalCount == other.totalGoalCount && status == other.status && statusMessage == other.statusMessage && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, workspaceId, project, workspace, name, dateCreated, dateUpdated, dateLastSampleReceived, description, dateLastEvaluated, dateOfNextEvaluation, passingGoalCount, failingGoalCount, totalGoalCount, status, statusMessage, links, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineRetrieveResponse{id=$id, projectId=$projectId, workspaceId=$workspaceId, project=$project, workspace=$workspace, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateLastSampleReceived=$dateLastSampleReceived, description=$description, dateLastEvaluated=$dateLastEvaluated, dateOfNextEvaluation=$dateOfNextEvaluation, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, status=$status, statusMessage=$statusMessage, links=$links, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateParams.kt deleted file mode 100644 index 763d8018..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateParams.kt +++ /dev/null @@ -1,486 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.core.toImmutable -import java.util.Objects -import java.util.Optional - -class InferencePipelineRowUpdateParams -constructor( - private val inferencePipelineId: String, - private val inferenceId: String, - private val row: JsonValue, - private val config: Config?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun inferencePipelineId(): String = inferencePipelineId - - fun inferenceId(): String = inferenceId - - fun row(): JsonValue = row - - fun config(): Optional = Optional.ofNullable(config) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): InferencePipelineRowUpdateBody { - return InferencePipelineRowUpdateBody( - row, - config, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.inferenceId.let { queryParams.put("inferenceId", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> inferencePipelineId - else -> "" - } - } - - @JsonDeserialize(builder = InferencePipelineRowUpdateBody.Builder::class) - @NoAutoDetect - class InferencePipelineRowUpdateBody - internal constructor( - private val row: JsonValue?, - private val config: Config?, - private val additionalProperties: Map, - ) { - - @JsonProperty("row") fun row(): JsonValue? = row - - @JsonProperty("config") fun config(): Config? = config - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var row: JsonValue? = null - private var config: Config? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineRowUpdateBody: InferencePipelineRowUpdateBody) = - apply { - this.row = inferencePipelineRowUpdateBody.row - this.config = inferencePipelineRowUpdateBody.config - additionalProperties(inferencePipelineRowUpdateBody.additionalProperties) - } - - @JsonProperty("row") fun row(row: JsonValue) = apply { this.row = row } - - @JsonProperty("config") fun config(config: Config) = apply { this.config = config } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineRowUpdateBody = - InferencePipelineRowUpdateBody( - checkNotNull(row) { "`row` is required but was not set" }, - config, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineRowUpdateBody && row == other.row && config == other.config && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(row, config, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineRowUpdateBody{row=$row, config=$config, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var inferencePipelineId: String? = null - private var inferenceId: String? = null - private var row: JsonValue? = null - private var config: Config? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineRowUpdateParams: InferencePipelineRowUpdateParams) = - apply { - inferencePipelineId = inferencePipelineRowUpdateParams.inferencePipelineId - inferenceId = inferencePipelineRowUpdateParams.inferenceId - row = inferencePipelineRowUpdateParams.row - config = inferencePipelineRowUpdateParams.config - additionalHeaders = inferencePipelineRowUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = - inferencePipelineRowUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - inferencePipelineRowUpdateParams.additionalBodyProperties.toMutableMap() - } - - fun inferencePipelineId(inferencePipelineId: String) = apply { - this.inferencePipelineId = inferencePipelineId - } - - /** Specify the inference id as a query param. */ - fun inferenceId(inferenceId: String) = apply { this.inferenceId = inferenceId } - - fun row(row: JsonValue) = apply { this.row = row } - - fun config(config: Config) = apply { this.config = config } - - 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) - } - - fun build(): InferencePipelineRowUpdateParams = - InferencePipelineRowUpdateParams( - checkNotNull(inferencePipelineId) { - "`inferencePipelineId` is required but was not set" - }, - checkNotNull(inferenceId) { "`inferenceId` is required but was not set" }, - checkNotNull(row) { "`row` is required but was not set" }, - config, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Config.Builder::class) - @NoAutoDetect - class Config - private constructor( - private val inferenceIdColumnName: String?, - private val latencyColumnName: String?, - private val timestampColumnName: String?, - private val groundTruthColumnName: String?, - private val humanFeedbackColumnName: String?, - private val additionalProperties: Map, - ) { - - /** - * Name of the column with the inference ids. This is useful if you want to update rows at a - * later point in time. If not provided, a unique id is generated by Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - fun inferenceIdColumnName(): String? = inferenceIdColumnName - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") fun latencyColumnName(): String? = latencyColumnName - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - fun timestampColumnName(): String? = timestampColumnName - - /** Name of the column with the ground truths. */ - @JsonProperty("groundTruthColumnName") - fun groundTruthColumnName(): String? = groundTruthColumnName - - /** Name of the column with human feedback. */ - @JsonProperty("humanFeedbackColumnName") - fun humanFeedbackColumnName(): String? = humanFeedbackColumnName - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var inferenceIdColumnName: String? = null - private var latencyColumnName: String? = null - private var timestampColumnName: String? = null - private var groundTruthColumnName: String? = null - private var humanFeedbackColumnName: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - this.inferenceIdColumnName = config.inferenceIdColumnName - this.latencyColumnName = config.latencyColumnName - this.timestampColumnName = config.timestampColumnName - this.groundTruthColumnName = config.groundTruthColumnName - this.humanFeedbackColumnName = config.humanFeedbackColumnName - additionalProperties(config.additionalProperties) - } - - /** - * Name of the column with the inference ids. This is useful if you want to update rows - * at a later point in time. If not provided, a unique id is generated by Openlayer. - */ - @JsonProperty("inferenceIdColumnName") - fun inferenceIdColumnName(inferenceIdColumnName: String) = apply { - this.inferenceIdColumnName = inferenceIdColumnName - } - - /** Name of the column with the latencies. */ - @JsonProperty("latencyColumnName") - fun latencyColumnName(latencyColumnName: String) = apply { - this.latencyColumnName = latencyColumnName - } - - /** - * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not - * provided, the upload timestamp is used. - */ - @JsonProperty("timestampColumnName") - fun timestampColumnName(timestampColumnName: String) = apply { - this.timestampColumnName = timestampColumnName - } - - /** Name of the column with the ground truths. */ - @JsonProperty("groundTruthColumnName") - fun groundTruthColumnName(groundTruthColumnName: String) = apply { - this.groundTruthColumnName = groundTruthColumnName - } - - /** Name of the column with human feedback. */ - @JsonProperty("humanFeedbackColumnName") - fun humanFeedbackColumnName(humanFeedbackColumnName: String) = apply { - this.humanFeedbackColumnName = humanFeedbackColumnName - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Config = - Config( - inferenceIdColumnName, - latencyColumnName, - timestampColumnName, - groundTruthColumnName, - humanFeedbackColumnName, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Config && inferenceIdColumnName == other.inferenceIdColumnName && latencyColumnName == other.latencyColumnName && timestampColumnName == other.timestampColumnName && groundTruthColumnName == other.groundTruthColumnName && humanFeedbackColumnName == other.humanFeedbackColumnName && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(inferenceIdColumnName, latencyColumnName, timestampColumnName, groundTruthColumnName, humanFeedbackColumnName, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Config{inferenceIdColumnName=$inferenceIdColumnName, latencyColumnName=$latencyColumnName, timestampColumnName=$timestampColumnName, groundTruthColumnName=$groundTruthColumnName, humanFeedbackColumnName=$humanFeedbackColumnName, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineRowUpdateParams && inferencePipelineId == other.inferencePipelineId && inferenceId == other.inferenceId && row == other.row && config == other.config && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, inferenceId, row, config, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "InferencePipelineRowUpdateParams{inferencePipelineId=$inferencePipelineId, inferenceId=$inferenceId, row=$row, config=$config, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateResponse.kt deleted file mode 100644 index 48e69d52..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateResponse.kt +++ /dev/null @@ -1,155 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.util.Objects - -@JsonDeserialize(builder = InferencePipelineRowUpdateResponse.Builder::class) -@NoAutoDetect -class InferencePipelineRowUpdateResponse -private constructor( - private val success: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun success(): Success = success.getRequired("success") - - @JsonProperty("success") @ExcludeMissing fun _success() = success - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InferencePipelineRowUpdateResponse = apply { - if (!validated) { - success() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var success: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineRowUpdateResponse: InferencePipelineRowUpdateResponse) = - apply { - this.success = inferencePipelineRowUpdateResponse.success - additionalProperties(inferencePipelineRowUpdateResponse.additionalProperties) - } - - fun success(success: Success) = success(JsonField.of(success)) - - @JsonProperty("success") - @ExcludeMissing - fun success(success: JsonField) = apply { this.success = success } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineRowUpdateResponse = - InferencePipelineRowUpdateResponse(success, additionalProperties.toImmutable()) - } - - class Success - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TRUE = of(true) - - @JvmStatic fun of(value: Boolean) = Success(JsonField.of(value)) - } - - enum class Known { - TRUE, - } - - enum class Value { - TRUE, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - TRUE -> Value.TRUE - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - TRUE -> Known.TRUE - else -> throw OpenlayerInvalidDataException("Unknown Success: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Success && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineRowUpdateResponse && success == other.success && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineRowUpdateResponse{success=$success, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineTestResultListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineTestResultListParams.kt deleted file mode 100644 index 4a8df2d2..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineTestResultListParams.kt +++ /dev/null @@ -1,388 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonCreator -import com.openlayer.api.core.Enum -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.util.Objects -import java.util.Optional - -class InferencePipelineTestResultListParams -constructor( - private val inferencePipelineId: String, - private val page: Long?, - private val perPage: Long?, - private val status: Status?, - private val type: Type?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) { - - fun inferencePipelineId(): String = inferencePipelineId - - fun page(): Optional = Optional.ofNullable(page) - - fun perPage(): Optional = Optional.ofNullable(perPage) - - fun status(): Optional = Optional.ofNullable(status) - - fun type(): Optional = Optional.ofNullable(type) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.page?.let { queryParams.put("page", listOf(it.toString())) } - this.perPage?.let { queryParams.put("perPage", listOf(it.toString())) } - this.status?.let { queryParams.put("status", listOf(it.toString())) } - this.type?.let { queryParams.put("type", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> inferencePipelineId - else -> "" - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var inferencePipelineId: String? = null - private var page: Long? = null - private var perPage: Long? = null - private var status: Status? = null - private var type: Type? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from( - inferencePipelineTestResultListParams: InferencePipelineTestResultListParams - ) = apply { - inferencePipelineId = inferencePipelineTestResultListParams.inferencePipelineId - page = inferencePipelineTestResultListParams.page - perPage = inferencePipelineTestResultListParams.perPage - status = inferencePipelineTestResultListParams.status - type = inferencePipelineTestResultListParams.type - additionalHeaders = inferencePipelineTestResultListParams.additionalHeaders.toBuilder() - additionalQueryParams = - inferencePipelineTestResultListParams.additionalQueryParams.toBuilder() - } - - fun inferencePipelineId(inferencePipelineId: String) = apply { - this.inferencePipelineId = inferencePipelineId - } - - /** The page to return in a paginated query. */ - fun page(page: Long) = apply { this.page = page } - - /** Maximum number of items to return per page. */ - fun perPage(perPage: Long) = apply { this.perPage = perPage } - - /** - * Filter list of test results by status. Available statuses are `running`, `passing`, - * `failing`, `skipped`, and `error`. - */ - fun status(status: Status) = apply { this.status = status } - - /** - * Filter objects by test type. Available types are `integrity`, `consistency`, - * `performance`, `fairness`, and `robustness`. - */ - fun type(type: Type) = apply { this.type = type } - - 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 build(): InferencePipelineTestResultListParams = - InferencePipelineTestResultListParams( - checkNotNull(inferencePipelineId) { - "`inferencePipelineId` is required but was not set" - }, - page, - perPage, - status, - type, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val RUNNING = of("running") - - @JvmField val PASSING = of("passing") - - @JvmField val FAILING = of("failing") - - @JvmField val SKIPPED = of("skipped") - - @JvmField val ERROR = of("error") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - } - - enum class Value { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - RUNNING -> Value.RUNNING - PASSING -> Value.PASSING - FAILING -> Value.FAILING - SKIPPED -> Value.SKIPPED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - RUNNING -> Known.RUNNING - PASSING -> Known.PASSING - FAILING -> Known.FAILING - SKIPPED -> Known.SKIPPED - ERROR -> Known.ERROR - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Type - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INTEGRITY = of("integrity") - - @JvmField val CONSISTENCY = of("consistency") - - @JvmField val PERFORMANCE = of("performance") - - @JvmField val FAIRNESS = of("fairness") - - @JvmField val ROBUSTNESS = of("robustness") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - enum class Known { - INTEGRITY, - CONSISTENCY, - PERFORMANCE, - FAIRNESS, - ROBUSTNESS, - } - - enum class Value { - INTEGRITY, - CONSISTENCY, - PERFORMANCE, - FAIRNESS, - ROBUSTNESS, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - INTEGRITY -> Value.INTEGRITY - CONSISTENCY -> Value.CONSISTENCY - PERFORMANCE -> Value.PERFORMANCE - FAIRNESS -> Value.FAIRNESS - ROBUSTNESS -> Value.ROBUSTNESS - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - INTEGRITY -> Known.INTEGRITY - CONSISTENCY -> Known.CONSISTENCY - PERFORMANCE -> Known.PERFORMANCE - FAIRNESS -> Known.FAIRNESS - ROBUSTNESS -> Known.ROBUSTNESS - else -> throw OpenlayerInvalidDataException("Unknown Type: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineTestResultListParams && inferencePipelineId == other.inferencePipelineId && page == other.page && perPage == other.perPage && status == other.status && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, page, perPage, status, type, additionalHeaders, additionalQueryParams) /* spotless:on */ - - override fun toString() = - "InferencePipelineTestResultListParams{inferencePipelineId=$inferencePipelineId, page=$page, perPage=$perPage, status=$status, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineTestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineTestResultListResponse.kt deleted file mode 100644 index eea537a6..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineTestResultListResponse.kt +++ /dev/null @@ -1,1365 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.openlayer.api.core.BaseDeserializer -import com.openlayer.api.core.BaseSerializer -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.getOrThrow -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InferencePipelineTestResultListResponse.Builder::class) -@NoAutoDetect -class InferencePipelineTestResultListResponse -private constructor( - private val items: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun items(): List = items.getRequired("items") - - @JsonProperty("items") @ExcludeMissing fun _items() = items - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InferencePipelineTestResultListResponse = apply { - if (!validated) { - items().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - inferencePipelineTestResultListResponse: InferencePipelineTestResultListResponse - ) = apply { - this.items = inferencePipelineTestResultListResponse.items - additionalProperties(inferencePipelineTestResultListResponse.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - @JsonProperty("items") - @ExcludeMissing - fun items(items: JsonField>) = apply { this.items = items } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineTestResultListResponse = - InferencePipelineTestResultListResponse( - items.map { it.toImmutable() }, - additionalProperties.toImmutable() - ) - } - - @JsonDeserialize(builder = Item.Builder::class) - @NoAutoDetect - class Item - private constructor( - private val id: JsonField, - private val goal: JsonField, - private val goalId: JsonField, - private val projectVersionId: JsonField, - private val inferencePipelineId: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val dateDataStarts: JsonField, - private val dateDataEnds: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** Project version (commit) id. */ - fun id(): String = id.getRequired("id") - - fun goal(): Optional = Optional.ofNullable(goal.getNullable("goal")) - - /** The test id. */ - fun goalId(): Optional = Optional.ofNullable(goalId.getNullable("goalId")) - - /** The project version (commit) id. */ - fun projectVersionId(): Optional = - Optional.ofNullable(projectVersionId.getNullable("projectVersionId")) - - /** The inference pipeline id. */ - fun inferencePipelineId(): Optional = - Optional.ofNullable(inferencePipelineId.getNullable("inferencePipelineId")) - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The data start date. */ - fun dateDataStarts(): Optional = - Optional.ofNullable(dateDataStarts.getNullable("dateDataStarts")) - - /** The data end date. */ - fun dateDataEnds(): Optional = - Optional.ofNullable(dateDataEnds.getNullable("dateDataEnds")) - - /** The status of the test. */ - fun status(): Status = status.getRequired("status") - - /** The status message. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - /** Project version (commit) id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("goal") @ExcludeMissing fun _goal() = goal - - /** The test id. */ - @JsonProperty("goalId") @ExcludeMissing fun _goalId() = goalId - - /** The project version (commit) id. */ - @JsonProperty("projectVersionId") @ExcludeMissing fun _projectVersionId() = projectVersionId - - /** The inference pipeline id. */ - @JsonProperty("inferencePipelineId") - @ExcludeMissing - fun _inferencePipelineId() = inferencePipelineId - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The data start date. */ - @JsonProperty("dateDataStarts") @ExcludeMissing fun _dateDataStarts() = dateDataStarts - - /** The data end date. */ - @JsonProperty("dateDataEnds") @ExcludeMissing fun _dateDataEnds() = dateDataEnds - - /** The status of the test. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The status message. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Item = apply { - if (!validated) { - id() - goal().map { it.validate() } - goalId() - projectVersionId() - inferencePipelineId() - dateCreated() - dateUpdated() - dateDataStarts() - dateDataEnds() - status() - statusMessage() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var goal: JsonField = JsonMissing.of() - private var goalId: JsonField = JsonMissing.of() - private var projectVersionId: JsonField = JsonMissing.of() - private var inferencePipelineId: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var dateDataStarts: JsonField = JsonMissing.of() - private var dateDataEnds: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - this.id = item.id - this.goal = item.goal - this.goalId = item.goalId - this.projectVersionId = item.projectVersionId - this.inferencePipelineId = item.inferencePipelineId - this.dateCreated = item.dateCreated - this.dateUpdated = item.dateUpdated - this.dateDataStarts = item.dateDataStarts - this.dateDataEnds = item.dateDataEnds - this.status = item.status - this.statusMessage = item.statusMessage - additionalProperties(item.additionalProperties) - } - - /** Project version (commit) id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** Project version (commit) id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun goal(goal: Goal) = goal(JsonField.of(goal)) - - @JsonProperty("goal") - @ExcludeMissing - fun goal(goal: JsonField) = apply { this.goal = goal } - - /** The test id. */ - fun goalId(goalId: String) = goalId(JsonField.of(goalId)) - - /** The test id. */ - @JsonProperty("goalId") - @ExcludeMissing - fun goalId(goalId: JsonField) = apply { this.goalId = goalId } - - /** The project version (commit) id. */ - fun projectVersionId(projectVersionId: String) = - projectVersionId(JsonField.of(projectVersionId)) - - /** The project version (commit) id. */ - @JsonProperty("projectVersionId") - @ExcludeMissing - fun projectVersionId(projectVersionId: JsonField) = apply { - this.projectVersionId = projectVersionId - } - - /** The inference pipeline id. */ - fun inferencePipelineId(inferencePipelineId: String) = - inferencePipelineId(JsonField.of(inferencePipelineId)) - - /** The inference pipeline id. */ - @JsonProperty("inferencePipelineId") - @ExcludeMissing - fun inferencePipelineId(inferencePipelineId: JsonField) = apply { - this.inferencePipelineId = inferencePipelineId - } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The data start date. */ - fun dateDataStarts(dateDataStarts: OffsetDateTime) = - dateDataStarts(JsonField.of(dateDataStarts)) - - /** The data start date. */ - @JsonProperty("dateDataStarts") - @ExcludeMissing - fun dateDataStarts(dateDataStarts: JsonField) = apply { - this.dateDataStarts = dateDataStarts - } - - /** The data end date. */ - fun dateDataEnds(dateDataEnds: OffsetDateTime) = - dateDataEnds(JsonField.of(dateDataEnds)) - - /** The data end date. */ - @JsonProperty("dateDataEnds") - @ExcludeMissing - fun dateDataEnds(dateDataEnds: JsonField) = apply { - this.dateDataEnds = dateDataEnds - } - - /** The status of the test. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of the test. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The status message. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The status message. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Item = - Item( - id, - goal, - goalId, - projectVersionId, - inferencePipelineId, - dateCreated, - dateUpdated, - dateDataStarts, - dateDataEnds, - status, - statusMessage, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val RUNNING = of("running") - - @JvmField val PASSING = of("passing") - - @JvmField val FAILING = of("failing") - - @JvmField val SKIPPED = of("skipped") - - @JvmField val ERROR = of("error") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - } - - enum class Value { - RUNNING, - PASSING, - FAILING, - SKIPPED, - ERROR, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - RUNNING -> Value.RUNNING - PASSING -> Value.PASSING - FAILING -> Value.FAILING - SKIPPED -> Value.SKIPPED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - RUNNING -> Known.RUNNING - PASSING -> Known.PASSING - FAILING -> Known.FAILING - SKIPPED -> Known.SKIPPED - ERROR -> Known.ERROR - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Goal.Builder::class) - @NoAutoDetect - class Goal - private constructor( - private val id: JsonField, - private val number: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonValue, - private val evaluationWindow: JsonField, - private val delayWindow: JsonField, - private val type: JsonField, - private val subtype: JsonField, - private val creatorId: JsonField, - private val originProjectVersionId: JsonField, - private val thresholds: JsonField>, - private val archived: JsonField, - private val dateArchived: JsonField, - private val suggested: JsonField, - private val commentCount: JsonField, - private val usesMlModel: JsonField, - private val usesValidationDataset: JsonField, - private val usesTrainingDataset: JsonField, - private val usesReferenceDataset: JsonField, - private val usesProductionData: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The test id. */ - fun id(): String = id.getRequired("id") - - /** The test number. */ - fun number(): Long = number.getRequired("number") - - /** The test name. */ - fun name(): String = name.getRequired("name") - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The evaluation window in seconds. Only applies to tests that use production data. */ - fun evaluationWindow(): Optional = - Optional.ofNullable(evaluationWindow.getNullable("evaluationWindow")) - - /** The delay window in seconds. Only applies to tests that use production data. */ - fun delayWindow(): Optional = - Optional.ofNullable(delayWindow.getNullable("delayWindow")) - - /** The test type. */ - fun type(): String = type.getRequired("type") - - /** The test subtype. */ - fun subtype(): String = subtype.getRequired("subtype") - - /** The test creator id. */ - fun creatorId(): Optional = - Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project version (commit) id where the test was created. */ - fun originProjectVersionId(): Optional = - Optional.ofNullable(originProjectVersionId.getNullable("originProjectVersionId")) - - fun thresholds(): List = thresholds.getRequired("thresholds") - - /** Whether the test is archived. */ - fun archived(): Optional = - Optional.ofNullable(archived.getNullable("archived")) - - /** The date the test was archived. */ - fun dateArchived(): Optional = - Optional.ofNullable(dateArchived.getNullable("dateArchived")) - - /** Whether the test is suggested or user-created. */ - fun suggested(): Boolean = suggested.getRequired("suggested") - - /** The number of comments on the test. */ - fun commentCount(): Long = commentCount.getRequired("commentCount") - - /** Whether the test uses an ML model. */ - fun usesMlModel(): Optional = - Optional.ofNullable(usesMlModel.getNullable("usesMlModel")) - - /** Whether the test uses a validation dataset. */ - fun usesValidationDataset(): Optional = - Optional.ofNullable(usesValidationDataset.getNullable("usesValidationDataset")) - - /** Whether the test uses a training dataset. */ - fun usesTrainingDataset(): Optional = - Optional.ofNullable(usesTrainingDataset.getNullable("usesTrainingDataset")) - - /** Whether the test uses a reference dataset (monitoring mode only). */ - fun usesReferenceDataset(): Optional = - Optional.ofNullable(usesReferenceDataset.getNullable("usesReferenceDataset")) - - /** Whether the test uses production data (monitoring mode only). */ - fun usesProductionData(): Optional = - Optional.ofNullable(usesProductionData.getNullable("usesProductionData")) - - /** The test id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The test number. */ - @JsonProperty("number") @ExcludeMissing fun _number() = number - - /** The test name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The test description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The evaluation window in seconds. Only applies to tests that use production data. */ - @JsonProperty("evaluationWindow") - @ExcludeMissing - fun _evaluationWindow() = evaluationWindow - - /** The delay window in seconds. Only applies to tests that use production data. */ - @JsonProperty("delayWindow") @ExcludeMissing fun _delayWindow() = delayWindow - - /** The test type. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type - - /** The test subtype. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype - - /** The test creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project version (commit) id where the test was created. */ - @JsonProperty("originProjectVersionId") - @ExcludeMissing - fun _originProjectVersionId() = originProjectVersionId - - @JsonProperty("thresholds") @ExcludeMissing fun _thresholds() = thresholds - - /** Whether the test is archived. */ - @JsonProperty("archived") @ExcludeMissing fun _archived() = archived - - /** The date the test was archived. */ - @JsonProperty("dateArchived") @ExcludeMissing fun _dateArchived() = dateArchived - - /** Whether the test is suggested or user-created. */ - @JsonProperty("suggested") @ExcludeMissing fun _suggested() = suggested - - /** The number of comments on the test. */ - @JsonProperty("commentCount") @ExcludeMissing fun _commentCount() = commentCount - - /** Whether the test uses an ML model. */ - @JsonProperty("usesMlModel") @ExcludeMissing fun _usesMlModel() = usesMlModel - - /** Whether the test uses a validation dataset. */ - @JsonProperty("usesValidationDataset") - @ExcludeMissing - fun _usesValidationDataset() = usesValidationDataset - - /** Whether the test uses a training dataset. */ - @JsonProperty("usesTrainingDataset") - @ExcludeMissing - fun _usesTrainingDataset() = usesTrainingDataset - - /** Whether the test uses a reference dataset (monitoring mode only). */ - @JsonProperty("usesReferenceDataset") - @ExcludeMissing - fun _usesReferenceDataset() = usesReferenceDataset - - /** Whether the test uses production data (monitoring mode only). */ - @JsonProperty("usesProductionData") - @ExcludeMissing - fun _usesProductionData() = usesProductionData - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Goal = apply { - if (!validated) { - id() - number() - name() - dateCreated() - dateUpdated() - evaluationWindow() - delayWindow() - type() - subtype() - creatorId() - originProjectVersionId() - thresholds().forEach { it.validate() } - archived() - dateArchived() - suggested() - commentCount() - usesMlModel() - usesValidationDataset() - usesTrainingDataset() - usesReferenceDataset() - usesProductionData() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var number: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonValue = JsonMissing.of() - private var evaluationWindow: JsonField = JsonMissing.of() - private var delayWindow: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var subtype: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var originProjectVersionId: JsonField = JsonMissing.of() - private var thresholds: JsonField> = JsonMissing.of() - private var archived: JsonField = JsonMissing.of() - private var dateArchived: JsonField = JsonMissing.of() - private var suggested: JsonField = JsonMissing.of() - private var commentCount: JsonField = JsonMissing.of() - private var usesMlModel: JsonField = JsonMissing.of() - private var usesValidationDataset: JsonField = JsonMissing.of() - private var usesTrainingDataset: JsonField = JsonMissing.of() - private var usesReferenceDataset: JsonField = JsonMissing.of() - private var usesProductionData: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(goal: Goal) = apply { - this.id = goal.id - this.number = goal.number - this.name = goal.name - this.dateCreated = goal.dateCreated - this.dateUpdated = goal.dateUpdated - this.description = goal.description - this.evaluationWindow = goal.evaluationWindow - this.delayWindow = goal.delayWindow - this.type = goal.type - this.subtype = goal.subtype - this.creatorId = goal.creatorId - this.originProjectVersionId = goal.originProjectVersionId - this.thresholds = goal.thresholds - this.archived = goal.archived - this.dateArchived = goal.dateArchived - this.suggested = goal.suggested - this.commentCount = goal.commentCount - this.usesMlModel = goal.usesMlModel - this.usesValidationDataset = goal.usesValidationDataset - this.usesTrainingDataset = goal.usesTrainingDataset - this.usesReferenceDataset = goal.usesReferenceDataset - this.usesProductionData = goal.usesProductionData - additionalProperties(goal.additionalProperties) - } - - /** The test id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The test id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The test number. */ - fun number(number: Long) = number(JsonField.of(number)) - - /** The test number. */ - @JsonProperty("number") - @ExcludeMissing - fun number(number: JsonField) = apply { this.number = number } - - /** The test name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The test name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = - dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The test description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonValue) = apply { this.description = description } - - /** - * The evaluation window in seconds. Only applies to tests that use production data. - */ - fun evaluationWindow(evaluationWindow: Double) = - evaluationWindow(JsonField.of(evaluationWindow)) - - /** - * The evaluation window in seconds. Only applies to tests that use production data. - */ - @JsonProperty("evaluationWindow") - @ExcludeMissing - fun evaluationWindow(evaluationWindow: JsonField) = apply { - this.evaluationWindow = evaluationWindow - } - - /** The delay window in seconds. Only applies to tests that use production data. */ - fun delayWindow(delayWindow: Double) = delayWindow(JsonField.of(delayWindow)) - - /** The delay window in seconds. Only applies to tests that use production data. */ - @JsonProperty("delayWindow") - @ExcludeMissing - fun delayWindow(delayWindow: JsonField) = apply { - this.delayWindow = delayWindow - } - - /** The test type. */ - fun type(type: String) = type(JsonField.of(type)) - - /** The test type. */ - @JsonProperty("type") - @ExcludeMissing - fun type(type: JsonField) = apply { this.type = type } - - /** The test subtype. */ - fun subtype(subtype: String) = subtype(JsonField.of(subtype)) - - /** The test subtype. */ - @JsonProperty("subtype") - @ExcludeMissing - fun subtype(subtype: JsonField) = apply { this.subtype = subtype } - - /** The test creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The test creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project version (commit) id where the test was created. */ - fun originProjectVersionId(originProjectVersionId: String) = - originProjectVersionId(JsonField.of(originProjectVersionId)) - - /** The project version (commit) id where the test was created. */ - @JsonProperty("originProjectVersionId") - @ExcludeMissing - fun originProjectVersionId(originProjectVersionId: JsonField) = apply { - this.originProjectVersionId = originProjectVersionId - } - - fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) - - @JsonProperty("thresholds") - @ExcludeMissing - fun thresholds(thresholds: JsonField>) = apply { - this.thresholds = thresholds - } - - /** Whether the test is archived. */ - fun archived(archived: Boolean) = archived(JsonField.of(archived)) - - /** Whether the test is archived. */ - @JsonProperty("archived") - @ExcludeMissing - fun archived(archived: JsonField) = apply { this.archived = archived } - - /** The date the test was archived. */ - fun dateArchived(dateArchived: OffsetDateTime) = - dateArchived(JsonField.of(dateArchived)) - - /** The date the test was archived. */ - @JsonProperty("dateArchived") - @ExcludeMissing - fun dateArchived(dateArchived: JsonField) = apply { - this.dateArchived = dateArchived - } - - /** Whether the test is suggested or user-created. */ - fun suggested(suggested: Boolean) = suggested(JsonField.of(suggested)) - - /** Whether the test is suggested or user-created. */ - @JsonProperty("suggested") - @ExcludeMissing - fun suggested(suggested: JsonField) = apply { this.suggested = suggested } - - /** The number of comments on the test. */ - fun commentCount(commentCount: Long) = commentCount(JsonField.of(commentCount)) - - /** The number of comments on the test. */ - @JsonProperty("commentCount") - @ExcludeMissing - fun commentCount(commentCount: JsonField) = apply { - this.commentCount = commentCount - } - - /** Whether the test uses an ML model. */ - fun usesMlModel(usesMlModel: Boolean) = usesMlModel(JsonField.of(usesMlModel)) - - /** Whether the test uses an ML model. */ - @JsonProperty("usesMlModel") - @ExcludeMissing - fun usesMlModel(usesMlModel: JsonField) = apply { - this.usesMlModel = usesMlModel - } - - /** Whether the test uses a validation dataset. */ - fun usesValidationDataset(usesValidationDataset: Boolean) = - usesValidationDataset(JsonField.of(usesValidationDataset)) - - /** Whether the test uses a validation dataset. */ - @JsonProperty("usesValidationDataset") - @ExcludeMissing - fun usesValidationDataset(usesValidationDataset: JsonField) = apply { - this.usesValidationDataset = usesValidationDataset - } - - /** Whether the test uses a training dataset. */ - fun usesTrainingDataset(usesTrainingDataset: Boolean) = - usesTrainingDataset(JsonField.of(usesTrainingDataset)) - - /** Whether the test uses a training dataset. */ - @JsonProperty("usesTrainingDataset") - @ExcludeMissing - fun usesTrainingDataset(usesTrainingDataset: JsonField) = apply { - this.usesTrainingDataset = usesTrainingDataset - } - - /** Whether the test uses a reference dataset (monitoring mode only). */ - fun usesReferenceDataset(usesReferenceDataset: Boolean) = - usesReferenceDataset(JsonField.of(usesReferenceDataset)) - - /** Whether the test uses a reference dataset (monitoring mode only). */ - @JsonProperty("usesReferenceDataset") - @ExcludeMissing - fun usesReferenceDataset(usesReferenceDataset: JsonField) = apply { - this.usesReferenceDataset = usesReferenceDataset - } - - /** Whether the test uses production data (monitoring mode only). */ - fun usesProductionData(usesProductionData: Boolean) = - usesProductionData(JsonField.of(usesProductionData)) - - /** Whether the test uses production data (monitoring mode only). */ - @JsonProperty("usesProductionData") - @ExcludeMissing - fun usesProductionData(usesProductionData: JsonField) = apply { - this.usesProductionData = usesProductionData - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Goal = - Goal( - id, - number, - name, - dateCreated, - dateUpdated, - description, - evaluationWindow, - delayWindow, - type, - subtype, - creatorId, - originProjectVersionId, - thresholds.map { it.toImmutable() }, - archived, - dateArchived, - suggested, - commentCount, - usesMlModel, - usesValidationDataset, - usesTrainingDataset, - usesReferenceDataset, - usesProductionData, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Threshold.Builder::class) - @NoAutoDetect - class Threshold - private constructor( - private val measurement: JsonField, - private val insightName: JsonField, - private val insightParameters: JsonField>, - private val operator: JsonField, - private val value: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The measurement to be evaluated. */ - fun measurement(): Optional = - Optional.ofNullable(measurement.getNullable("measurement")) - - /** The insight name to be evaluated. */ - fun insightName(): Optional = - Optional.ofNullable(insightName.getNullable("insightName")) - - fun insightParameters(): Optional> = - Optional.ofNullable(insightParameters.getNullable("insightParameters")) - - /** The operator to be used for the evaluation. */ - fun operator(): Optional = - Optional.ofNullable(operator.getNullable("operator")) - - /** The value to be compared. */ - fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - - /** The measurement to be evaluated. */ - @JsonProperty("measurement") @ExcludeMissing fun _measurement() = measurement - - /** The insight name to be evaluated. */ - @JsonProperty("insightName") @ExcludeMissing fun _insightName() = insightName - - @JsonProperty("insightParameters") - @ExcludeMissing - fun _insightParameters() = insightParameters - - /** The operator to be used for the evaluation. */ - @JsonProperty("operator") @ExcludeMissing fun _operator() = operator - - /** The value to be compared. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Threshold = apply { - if (!validated) { - measurement() - insightName() - insightParameters() - operator() - value() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var measurement: JsonField = JsonMissing.of() - private var insightName: JsonField = JsonMissing.of() - private var insightParameters: JsonField> = JsonMissing.of() - private var operator: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(threshold: Threshold) = apply { - this.measurement = threshold.measurement - this.insightName = threshold.insightName - this.insightParameters = threshold.insightParameters - this.operator = threshold.operator - this.value = threshold.value - additionalProperties(threshold.additionalProperties) - } - - /** The measurement to be evaluated. */ - fun measurement(measurement: String) = measurement(JsonField.of(measurement)) - - /** The measurement to be evaluated. */ - @JsonProperty("measurement") - @ExcludeMissing - fun measurement(measurement: JsonField) = apply { - this.measurement = measurement - } - - /** The insight name to be evaluated. */ - fun insightName(insightName: String) = insightName(JsonField.of(insightName)) - - /** The insight name to be evaluated. */ - @JsonProperty("insightName") - @ExcludeMissing - fun insightName(insightName: JsonField) = apply { - this.insightName = insightName - } - - fun insightParameters(insightParameters: List) = - insightParameters(JsonField.of(insightParameters)) - - @JsonProperty("insightParameters") - @ExcludeMissing - fun insightParameters(insightParameters: JsonField>) = apply { - this.insightParameters = insightParameters - } - - /** The operator to be used for the evaluation. */ - fun operator(operator: String) = operator(JsonField.of(operator)) - - /** The operator to be used for the evaluation. */ - @JsonProperty("operator") - @ExcludeMissing - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** The value to be compared. */ - fun value(value: Value) = value(JsonField.of(value)) - - /** The value to be compared. */ - @JsonProperty("value") - @ExcludeMissing - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Threshold = - Threshold( - measurement, - insightName, - insightParameters.map { it.toImmutable() }, - operator, - value, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val number: Double? = null, - private val bool: Boolean? = null, - private val string: String? = null, - private val strings: List? = null, - private val _json: JsonValue? = null, - ) { - - private var validated: Boolean = false - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun string(): Optional = Optional.ofNullable(string) - - fun strings(): Optional> = Optional.ofNullable(strings) - - fun isNumber(): Boolean = number != null - - fun isBool(): Boolean = bool != null - - fun isString(): Boolean = string != null - - fun isStrings(): Boolean = strings != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun asString(): String = string.getOrThrow("string") - - fun asStrings(): List = strings.getOrThrow("strings") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T { - return when { - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - string != null -> visitor.visitString(string) - strings != null -> visitor.visitStrings(strings) - else -> visitor.unknown(_json) - } - } - - fun validate(): Value = apply { - if (!validated) { - if ( - number == null && bool == null && string == null && strings == null - ) { - throw OpenlayerInvalidDataException("Unknown Value: $_json") - } - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Value && number == other.number && bool == other.bool && string == other.string && strings == other.strings /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(number, bool, string, strings) /* spotless:on */ - - override fun toString(): String = - when { - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - string != null -> "Value{string=$string}" - strings != null -> "Value{strings=$strings}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) - - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) - } - - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - fun visitString(string: String): T - - fun visitStrings(strings: List): T - - fun unknown(json: JsonValue?): T { - throw OpenlayerInvalidDataException("Unknown Value: $json") - } - } - - class Deserializer : BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Value { - val json = JsonValue.fromJsonNode(node) - - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(bool = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Value(strings = it, _json = json) - } - - return Value(_json = json) - } - } - - class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value.string != null -> generator.writeObject(value.string) - value.strings != null -> generator.writeObject(value.strings) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Threshold && measurement == other.measurement && insightName == other.insightName && insightParameters == other.insightParameters && operator == other.operator && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(measurement, insightName, insightParameters, operator, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Threshold{measurement=$measurement, insightName=$insightName, insightParameters=$insightParameters, operator=$operator, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Goal && id == other.id && number == other.number && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && evaluationWindow == other.evaluationWindow && delayWindow == other.delayWindow && type == other.type && subtype == other.subtype && creatorId == other.creatorId && originProjectVersionId == other.originProjectVersionId && thresholds == other.thresholds && archived == other.archived && dateArchived == other.dateArchived && suggested == other.suggested && commentCount == other.commentCount && usesMlModel == other.usesMlModel && usesValidationDataset == other.usesValidationDataset && usesTrainingDataset == other.usesTrainingDataset && usesReferenceDataset == other.usesReferenceDataset && usesProductionData == other.usesProductionData && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, number, name, dateCreated, dateUpdated, description, evaluationWindow, delayWindow, type, subtype, creatorId, originProjectVersionId, thresholds, archived, dateArchived, suggested, commentCount, usesMlModel, usesValidationDataset, usesTrainingDataset, usesReferenceDataset, usesProductionData, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Goal{id=$id, number=$number, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, evaluationWindow=$evaluationWindow, delayWindow=$delayWindow, type=$type, subtype=$subtype, creatorId=$creatorId, originProjectVersionId=$originProjectVersionId, thresholds=$thresholds, archived=$archived, dateArchived=$dateArchived, suggested=$suggested, commentCount=$commentCount, usesMlModel=$usesMlModel, usesValidationDataset=$usesValidationDataset, usesTrainingDataset=$usesTrainingDataset, usesReferenceDataset=$usesReferenceDataset, usesProductionData=$usesProductionData, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && goal == other.goal && goalId == other.goalId && projectVersionId == other.projectVersionId && inferencePipelineId == other.inferencePipelineId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && dateDataStarts == other.dateDataStarts && dateDataEnds == other.dateDataEnds && status == other.status && statusMessage == other.statusMessage && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, goal, goalId, projectVersionId, inferencePipelineId, dateCreated, dateUpdated, dateDataStarts, dateDataEnds, status, statusMessage, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, goal=$goal, goalId=$goalId, projectVersionId=$projectVersionId, inferencePipelineId=$inferencePipelineId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateDataStarts=$dateDataStarts, dateDataEnds=$dateDataEnds, status=$status, statusMessage=$statusMessage, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineTestResultListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineTestResultListResponse{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt deleted file mode 100644 index 14da868d..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt +++ /dev/null @@ -1,364 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.core.toImmutable -import java.util.Objects -import java.util.Optional - -class InferencePipelineUpdateParams -constructor( - private val inferencePipelineId: String, - private val description: String?, - private val name: String?, - private val referenceDatasetUri: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun inferencePipelineId(): String = inferencePipelineId - - fun description(): Optional = Optional.ofNullable(description) - - fun name(): Optional = Optional.ofNullable(name) - - fun referenceDatasetUri(): Optional = Optional.ofNullable(referenceDatasetUri) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): InferencePipelineUpdateBody { - return InferencePipelineUpdateBody( - description, - name, - referenceDatasetUri, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> inferencePipelineId - else -> "" - } - } - - @JsonDeserialize(builder = InferencePipelineUpdateBody.Builder::class) - @NoAutoDetect - class InferencePipelineUpdateBody - internal constructor( - private val description: String?, - private val name: String?, - private val referenceDatasetUri: String?, - private val additionalProperties: Map, - ) { - - /** The inference pipeline description. */ - @JsonProperty("description") fun description(): String? = description - - /** The inference pipeline name. */ - @JsonProperty("name") fun name(): String? = name - - /** - * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to - * handle your reference dataset updates. - */ - @JsonProperty("referenceDatasetUri") - fun referenceDatasetUri(): String? = referenceDatasetUri - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var description: String? = null - private var name: String? = null - private var referenceDatasetUri: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineUpdateBody: InferencePipelineUpdateBody) = apply { - this.description = inferencePipelineUpdateBody.description - this.name = inferencePipelineUpdateBody.name - this.referenceDatasetUri = inferencePipelineUpdateBody.referenceDatasetUri - additionalProperties(inferencePipelineUpdateBody.additionalProperties) - } - - /** The inference pipeline description. */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } - - /** The inference pipeline name. */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - /** - * The storage uri of your reference dataset. We recommend using the Python SDK or the - * UI to handle your reference dataset updates. - */ - @JsonProperty("referenceDatasetUri") - fun referenceDatasetUri(referenceDatasetUri: String) = apply { - this.referenceDatasetUri = referenceDatasetUri - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineUpdateBody = - InferencePipelineUpdateBody( - description, - name, - referenceDatasetUri, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineUpdateBody && description == other.description && name == other.name && referenceDatasetUri == other.referenceDatasetUri && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(description, name, referenceDatasetUri, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineUpdateBody{description=$description, name=$name, referenceDatasetUri=$referenceDatasetUri, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var inferencePipelineId: String? = null - private var description: String? = null - private var name: String? = null - private var referenceDatasetUri: 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(inferencePipelineUpdateParams: InferencePipelineUpdateParams) = apply { - inferencePipelineId = inferencePipelineUpdateParams.inferencePipelineId - description = inferencePipelineUpdateParams.description - name = inferencePipelineUpdateParams.name - referenceDatasetUri = inferencePipelineUpdateParams.referenceDatasetUri - additionalHeaders = inferencePipelineUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = inferencePipelineUpdateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - inferencePipelineUpdateParams.additionalBodyProperties.toMutableMap() - } - - fun inferencePipelineId(inferencePipelineId: String) = apply { - this.inferencePipelineId = inferencePipelineId - } - - /** The inference pipeline description. */ - fun description(description: String) = apply { this.description = description } - - /** The inference pipeline name. */ - fun name(name: String) = apply { this.name = name } - - /** - * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to - * handle your reference dataset updates. - */ - fun referenceDatasetUri(referenceDatasetUri: String) = apply { - this.referenceDatasetUri = referenceDatasetUri - } - - 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) - } - - fun build(): InferencePipelineUpdateParams = - InferencePipelineUpdateParams( - checkNotNull(inferencePipelineId) { - "`inferencePipelineId` is required but was not set" - }, - description, - name, - referenceDatasetUri, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineUpdateParams && inferencePipelineId == other.inferencePipelineId && description == other.description && name == other.name && referenceDatasetUri == other.referenceDatasetUri && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, description, name, referenceDatasetUri, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "InferencePipelineUpdateParams{inferencePipelineId=$inferencePipelineId, description=$description, name=$name, referenceDatasetUri=$referenceDatasetUri, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt deleted file mode 100644 index b570b222..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt +++ /dev/null @@ -1,2067 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = InferencePipelineUpdateResponse.Builder::class) -@NoAutoDetect -class InferencePipelineUpdateResponse -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val workspaceId: JsonField, - private val project: JsonField, - private val workspace: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val dateLastSampleReceived: JsonField, - private val description: JsonField, - private val dateLastEvaluated: JsonField, - private val dateOfNextEvaluation: JsonField, - private val passingGoalCount: JsonField, - private val failingGoalCount: JsonField, - private val totalGoalCount: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val links: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The inference pipeline id. */ - fun id(): String = id.getRequired("id") - - /** The project id. */ - fun projectId(): String = projectId.getRequired("projectId") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - fun project(): Optional = Optional.ofNullable(project.getNullable("project")) - - fun workspace(): Optional = Optional.ofNullable(workspace.getNullable("workspace")) - - /** The inference pipeline name. */ - fun name(): String = name.getRequired("name") - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The last data sample received date. */ - fun dateLastSampleReceived(): Optional = - Optional.ofNullable(dateLastSampleReceived.getNullable("dateLastSampleReceived")) - - /** The inference pipeline description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The last test evaluation date. */ - fun dateLastEvaluated(): Optional = - Optional.ofNullable(dateLastEvaluated.getNullable("dateLastEvaluated")) - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(): Optional = - Optional.ofNullable(dateOfNextEvaluation.getNullable("dateOfNextEvaluation")) - - /** The number of tests passing. */ - fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") - - /** The number of tests failing. */ - fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") - - /** The total number of tests. */ - fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") - - /** The status of test evaluation for the inference pipeline. */ - fun status(): Status = status.getRequired("status") - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - fun links(): Links = links.getRequired("links") - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The project id. */ - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - @JsonProperty("project") @ExcludeMissing fun _project() = project - - @JsonProperty("workspace") @ExcludeMissing fun _workspace() = workspace - - /** The inference pipeline name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun _dateLastSampleReceived() = dateLastSampleReceived - - /** The inference pipeline description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") @ExcludeMissing fun _dateLastEvaluated() = dateLastEvaluated - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun _dateOfNextEvaluation() = dateOfNextEvaluation - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): InferencePipelineUpdateResponse = apply { - if (!validated) { - id() - projectId() - workspaceId() - project().map { it.validate() } - workspace().map { it.validate() } - name() - dateCreated() - dateUpdated() - dateLastSampleReceived() - description() - dateLastEvaluated() - dateOfNextEvaluation() - passingGoalCount() - failingGoalCount() - totalGoalCount() - status() - statusMessage() - links().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var project: JsonField = JsonMissing.of() - private var workspace: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var dateLastSampleReceived: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dateLastEvaluated: JsonField = JsonMissing.of() - private var dateOfNextEvaluation: JsonField = JsonMissing.of() - private var passingGoalCount: JsonField = JsonMissing.of() - private var failingGoalCount: JsonField = JsonMissing.of() - private var totalGoalCount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inferencePipelineUpdateResponse: InferencePipelineUpdateResponse) = - apply { - this.id = inferencePipelineUpdateResponse.id - this.projectId = inferencePipelineUpdateResponse.projectId - this.workspaceId = inferencePipelineUpdateResponse.workspaceId - this.project = inferencePipelineUpdateResponse.project - this.workspace = inferencePipelineUpdateResponse.workspace - this.name = inferencePipelineUpdateResponse.name - this.dateCreated = inferencePipelineUpdateResponse.dateCreated - this.dateUpdated = inferencePipelineUpdateResponse.dateUpdated - this.dateLastSampleReceived = inferencePipelineUpdateResponse.dateLastSampleReceived - this.description = inferencePipelineUpdateResponse.description - this.dateLastEvaluated = inferencePipelineUpdateResponse.dateLastEvaluated - this.dateOfNextEvaluation = inferencePipelineUpdateResponse.dateOfNextEvaluation - this.passingGoalCount = inferencePipelineUpdateResponse.passingGoalCount - this.failingGoalCount = inferencePipelineUpdateResponse.failingGoalCount - this.totalGoalCount = inferencePipelineUpdateResponse.totalGoalCount - this.status = inferencePipelineUpdateResponse.status - this.statusMessage = inferencePipelineUpdateResponse.statusMessage - this.links = inferencePipelineUpdateResponse.links - additionalProperties(inferencePipelineUpdateResponse.additionalProperties) - } - - /** The inference pipeline id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The project id. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** The project id. */ - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } - - fun project(project: Project) = project(JsonField.of(project)) - - @JsonProperty("project") - @ExcludeMissing - fun project(project: JsonField) = apply { this.project = project } - - fun workspace(workspace: Workspace) = workspace(JsonField.of(workspace)) - - @JsonProperty("workspace") - @ExcludeMissing - fun workspace(workspace: JsonField) = apply { this.workspace = workspace } - - /** The inference pipeline name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The inference pipeline name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The last data sample received date. */ - fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime) = - dateLastSampleReceived(JsonField.of(dateLastSampleReceived)) - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { - this.dateLastSampleReceived = dateLastSampleReceived - } - - /** The inference pipeline description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The inference pipeline description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The last test evaluation date. */ - fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime) = - dateLastEvaluated(JsonField.of(dateLastEvaluated)) - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") - @ExcludeMissing - fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { - this.dateLastEvaluated = dateLastEvaluated - } - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime) = - dateOfNextEvaluation(JsonField.of(dateOfNextEvaluation)) - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { - this.dateOfNextEvaluation = dateOfNextEvaluation - } - - /** The number of tests passing. */ - fun passingGoalCount(passingGoalCount: Long) = - passingGoalCount(JsonField.of(passingGoalCount)) - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") - @ExcludeMissing - fun passingGoalCount(passingGoalCount: JsonField) = apply { - this.passingGoalCount = passingGoalCount - } - - /** The number of tests failing. */ - fun failingGoalCount(failingGoalCount: Long) = - failingGoalCount(JsonField.of(failingGoalCount)) - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") - @ExcludeMissing - fun failingGoalCount(failingGoalCount: JsonField) = apply { - this.failingGoalCount = failingGoalCount - } - - /** The total number of tests. */ - fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") - @ExcludeMissing - fun totalGoalCount(totalGoalCount: JsonField) = apply { - this.totalGoalCount = totalGoalCount - } - - /** The status of test evaluation for the inference pipeline. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - fun links(links: Links) = links(JsonField.of(links)) - - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): InferencePipelineUpdateResponse = - InferencePipelineUpdateResponse( - id, - projectId, - workspaceId, - project, - workspace, - name, - dateCreated, - dateUpdated, - dateLastSampleReceived, - description, - dateLastEvaluated, - dateOfNextEvaluation, - passingGoalCount, - failingGoalCount, - totalGoalCount, - status, - statusMessage, - links, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Project.Builder::class) - @NoAutoDetect - class Project - private constructor( - private val id: JsonField, - private val workspaceId: JsonField, - private val creatorId: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonField, - private val source: JsonField, - private val taskType: JsonField, - private val versionCount: JsonField, - private val inferencePipelineCount: JsonField, - private val goalCount: JsonField, - private val developmentGoalCount: JsonField, - private val monitoringGoalCount: JsonField, - private val links: JsonField, - private val gitRepo: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The project id. */ - fun id(): String = id.getRequired("id") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - /** The project creator id. */ - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project name. */ - fun name(): String = name.getRequired("name") - - /** The project creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The project last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The project description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The source of the project. */ - fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - - /** The task type of the project. */ - fun taskType(): TaskType = taskType.getRequired("taskType") - - /** The number of versions (commits) in the project. */ - fun versionCount(): Long = versionCount.getRequired("versionCount") - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(): Long = - inferencePipelineCount.getRequired("inferencePipelineCount") - - /** The total number of tests in the project. */ - fun goalCount(): Long = goalCount.getRequired("goalCount") - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") - - /** Links to the project. */ - fun links(): Links = links.getRequired("links") - - fun gitRepo(): Optional = Optional.ofNullable(gitRepo.getNullable("gitRepo")) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The project creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The project description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The source of the project. */ - @JsonProperty("source") @ExcludeMissing fun _source() = source - - /** The task type of the project. */ - @JsonProperty("taskType") @ExcludeMissing fun _taskType() = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") @ExcludeMissing fun _versionCount() = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun _inferencePipelineCount() = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") @ExcludeMissing fun _goalCount() = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun _developmentGoalCount() = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun _monitoringGoalCount() = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo() = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Project = apply { - if (!validated) { - id() - workspaceId() - creatorId() - name() - dateCreated() - dateUpdated() - description() - source() - taskType() - versionCount() - inferencePipelineCount() - goalCount() - developmentGoalCount() - monitoringGoalCount() - links().validate() - gitRepo().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var taskType: JsonField = JsonMissing.of() - private var versionCount: JsonField = JsonMissing.of() - private var inferencePipelineCount: JsonField = JsonMissing.of() - private var goalCount: JsonField = JsonMissing.of() - private var developmentGoalCount: JsonField = JsonMissing.of() - private var monitoringGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var gitRepo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(project: Project) = apply { - this.id = project.id - this.workspaceId = project.workspaceId - this.creatorId = project.creatorId - this.name = project.name - this.dateCreated = project.dateCreated - this.dateUpdated = project.dateUpdated - this.description = project.description - this.source = project.source - this.taskType = project.taskType - this.versionCount = project.versionCount - this.inferencePipelineCount = project.inferencePipelineCount - this.goalCount = project.goalCount - this.developmentGoalCount = project.developmentGoalCount - this.monitoringGoalCount = project.monitoringGoalCount - this.links = project.links - this.gitRepo = project.gitRepo - additionalProperties(project.additionalProperties) - } - - /** The project id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { - this.workspaceId = workspaceId - } - - /** The project creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The project creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The project name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The project creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The project last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The project description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The project description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - /** The source of the project. */ - fun source(source: Source) = source(JsonField.of(source)) - - /** The source of the project. */ - @JsonProperty("source") - @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) - - /** The task type of the project. */ - @JsonProperty("taskType") - @ExcludeMissing - fun taskType(taskType: JsonField) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - @ExcludeMissing - fun versionCount(versionCount: JsonField) = apply { - this.versionCount = versionCount - } - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(inferencePipelineCount: Long) = - inferencePipelineCount(JsonField.of(inferencePipelineCount)) - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - @ExcludeMissing - fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(developmentGoalCount: Long) = - developmentGoalCount(JsonField.of(developmentGoalCount)) - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun developmentGoalCount(developmentGoalCount: JsonField) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(monitoringGoalCount: Long) = - monitoringGoalCount(JsonField.of(monitoringGoalCount)) - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - fun links(links: Links) = links(JsonField.of(links)) - - /** Links to the project. */ - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun gitRepo(gitRepo: GitRepo) = gitRepo(JsonField.of(gitRepo)) - - @JsonProperty("gitRepo") - @ExcludeMissing - fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Project = - Project( - id, - workspaceId, - creatorId, - name, - dateCreated, - dateUpdated, - description, - source, - taskType, - versionCount, - inferencePipelineCount, - goalCount, - developmentGoalCount, - monitoringGoalCount, - links, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: JsonField, - private val gitId: JsonField, - private val dateConnected: JsonField, - private val dateUpdated: JsonField, - private val branch: JsonField, - private val name: JsonField, - private val private_: JsonField, - private val slug: JsonField, - private val url: JsonField, - private val rootDir: JsonField, - private val projectId: JsonField, - private val gitAccountId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun gitId(): Long = gitId.getRequired("gitId") - - fun dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - - fun name(): String = name.getRequired("name") - - fun private_(): Boolean = private_.getRequired("private") - - fun slug(): String = slug.getRequired("slug") - - fun url(): String = url.getRequired("url") - - fun rootDir(): Optional = Optional.ofNullable(rootDir.getNullable("rootDir")) - - fun projectId(): String = projectId.getRequired("projectId") - - fun gitAccountId(): String = gitAccountId.getRequired("gitAccountId") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("gitId") @ExcludeMissing fun _gitId() = gitId - - @JsonProperty("dateConnected") @ExcludeMissing fun _dateConnected() = dateConnected - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("private") @ExcludeMissing fun _private_() = private_ - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("rootDir") @ExcludeMissing fun _rootDir() = rootDir - - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("gitAccountId") @ExcludeMissing fun _gitAccountId() = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitRepo = apply { - if (!validated) { - id() - gitId() - dateConnected() - dateUpdated() - branch() - name() - private_() - slug() - url() - rootDir() - projectId() - gitAccountId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var gitId: JsonField = JsonMissing.of() - private var dateConnected: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var private_: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var rootDir: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var gitAccountId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) - - @JsonProperty("gitId") - @ExcludeMissing - fun gitId(gitId: JsonField) = apply { this.gitId = gitId } - - fun dateConnected(dateConnected: OffsetDateTime) = - dateConnected(JsonField.of(dateConnected)) - - @JsonProperty("dateConnected") - @ExcludeMissing - fun dateConnected(dateConnected: JsonField) = apply { - this.dateConnected = dateConnected - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun branch(branch: String) = branch(JsonField.of(branch)) - - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun private_(private_: Boolean) = private_(JsonField.of(private_)) - - @JsonProperty("private") - @ExcludeMissing - fun private_(private_: JsonField) = apply { this.private_ = private_ } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) - - @JsonProperty("rootDir") - @ExcludeMissing - fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) - - @JsonProperty("gitAccountId") - @ExcludeMissing - fun gitAccountId(gitAccountId: JsonField) = apply { - this.gitAccountId = gitAccountId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - id, - gitId, - dateConnected, - dateUpdated, - branch, - name, - private_, - slug, - url, - rootDir, - projectId, - gitAccountId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Project && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Project{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Workspace.Builder::class) - @NoAutoDetect - class Workspace - private constructor( - private val id: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val creatorId: JsonField, - private val inviteCode: JsonField, - private val wildcardDomains: JsonField>, - private val projectCount: JsonField, - private val memberCount: JsonField, - private val monthlyUsage: JsonField>, - private val inviteCount: JsonField, - private val periodStartDate: JsonField, - private val periodEndDate: JsonField, - private val samlOnlyAccess: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - fun slug(): String = slug.getRequired("slug") - - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - fun inviteCode(): Optional = - Optional.ofNullable(inviteCode.getNullable("inviteCode")) - - fun wildcardDomains(): Optional> = - Optional.ofNullable(wildcardDomains.getNullable("wildcardDomains")) - - fun projectCount(): Long = projectCount.getRequired("projectCount") - - fun memberCount(): Long = memberCount.getRequired("memberCount") - - fun monthlyUsage(): Optional> = - Optional.ofNullable(monthlyUsage.getNullable("monthlyUsage")) - - fun inviteCount(): Long = inviteCount.getRequired("inviteCount") - - fun periodStartDate(): Optional = - Optional.ofNullable(periodStartDate.getNullable("periodStartDate")) - - fun periodEndDate(): Optional = - Optional.ofNullable(periodEndDate.getNullable("periodEndDate")) - - fun samlOnlyAccess(): Optional = - Optional.ofNullable(samlOnlyAccess.getNullable("samlOnlyAccess")) - - fun status(): Status = status.getRequired("status") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - @JsonProperty("inviteCode") @ExcludeMissing fun _inviteCode() = inviteCode - - @JsonProperty("wildcardDomains") @ExcludeMissing fun _wildcardDomains() = wildcardDomains - - @JsonProperty("projectCount") @ExcludeMissing fun _projectCount() = projectCount - - @JsonProperty("memberCount") @ExcludeMissing fun _memberCount() = memberCount - - @JsonProperty("monthlyUsage") @ExcludeMissing fun _monthlyUsage() = monthlyUsage - - @JsonProperty("inviteCount") @ExcludeMissing fun _inviteCount() = inviteCount - - @JsonProperty("periodStartDate") @ExcludeMissing fun _periodStartDate() = periodStartDate - - @JsonProperty("periodEndDate") @ExcludeMissing fun _periodEndDate() = periodEndDate - - @JsonProperty("samlOnlyAccess") @ExcludeMissing fun _samlOnlyAccess() = samlOnlyAccess - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Workspace = apply { - if (!validated) { - id() - name() - slug() - dateCreated() - dateUpdated() - creatorId() - inviteCode() - wildcardDomains() - projectCount() - memberCount() - monthlyUsage().map { it.forEach { it.validate() } } - inviteCount() - periodStartDate() - periodEndDate() - samlOnlyAccess() - status() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var inviteCode: JsonField = JsonMissing.of() - private var wildcardDomains: JsonField> = JsonMissing.of() - private var projectCount: JsonField = JsonMissing.of() - private var memberCount: JsonField = JsonMissing.of() - private var monthlyUsage: JsonField> = JsonMissing.of() - private var inviteCount: JsonField = JsonMissing.of() - private var periodStartDate: JsonField = JsonMissing.of() - private var periodEndDate: JsonField = JsonMissing.of() - private var samlOnlyAccess: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(workspace: Workspace) = apply { - this.id = workspace.id - this.name = workspace.name - this.slug = workspace.slug - this.dateCreated = workspace.dateCreated - this.dateUpdated = workspace.dateUpdated - this.creatorId = workspace.creatorId - this.inviteCode = workspace.inviteCode - this.wildcardDomains = workspace.wildcardDomains - this.projectCount = workspace.projectCount - this.memberCount = workspace.memberCount - this.monthlyUsage = workspace.monthlyUsage - this.inviteCount = workspace.inviteCount - this.periodStartDate = workspace.periodStartDate - this.periodEndDate = workspace.periodEndDate - this.samlOnlyAccess = workspace.samlOnlyAccess - this.status = workspace.status - additionalProperties(workspace.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) - - @JsonProperty("inviteCode") - @ExcludeMissing - fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } - - fun wildcardDomains(wildcardDomains: List) = - wildcardDomains(JsonField.of(wildcardDomains)) - - @JsonProperty("wildcardDomains") - @ExcludeMissing - fun wildcardDomains(wildcardDomains: JsonField>) = apply { - this.wildcardDomains = wildcardDomains - } - - fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) - - @JsonProperty("projectCount") - @ExcludeMissing - fun projectCount(projectCount: JsonField) = apply { - this.projectCount = projectCount - } - - fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) - - @JsonProperty("memberCount") - @ExcludeMissing - fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } - - fun monthlyUsage(monthlyUsage: List) = - monthlyUsage(JsonField.of(monthlyUsage)) - - @JsonProperty("monthlyUsage") - @ExcludeMissing - fun monthlyUsage(monthlyUsage: JsonField>) = apply { - this.monthlyUsage = monthlyUsage - } - - fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) - - @JsonProperty("inviteCount") - @ExcludeMissing - fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } - - fun periodStartDate(periodStartDate: OffsetDateTime) = - periodStartDate(JsonField.of(periodStartDate)) - - @JsonProperty("periodStartDate") - @ExcludeMissing - fun periodStartDate(periodStartDate: JsonField) = apply { - this.periodStartDate = periodStartDate - } - - fun periodEndDate(periodEndDate: OffsetDateTime) = - periodEndDate(JsonField.of(periodEndDate)) - - @JsonProperty("periodEndDate") - @ExcludeMissing - fun periodEndDate(periodEndDate: JsonField) = apply { - this.periodEndDate = periodEndDate - } - - fun samlOnlyAccess(samlOnlyAccess: Boolean) = - samlOnlyAccess(JsonField.of(samlOnlyAccess)) - - @JsonProperty("samlOnlyAccess") - @ExcludeMissing - fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { - this.samlOnlyAccess = samlOnlyAccess - } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Workspace = - Workspace( - id, - name, - slug, - dateCreated, - dateUpdated, - creatorId, - inviteCode, - wildcardDomains.map { it.toImmutable() }, - projectCount, - memberCount, - monthlyUsage.map { it.toImmutable() }, - inviteCount, - periodStartDate, - periodEndDate, - samlOnlyAccess, - status, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val PAST_DUE = of("past_due") - - @JvmField val UNPAID = of("unpaid") - - @JvmField val CANCELED = of("canceled") - - @JvmField val INCOMPLETE = of("incomplete") - - @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") - - @JvmField val TRIALING = of("trialing") - - @JvmField val PAUSED = of("paused") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - } - - enum class Value { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - PAST_DUE -> Value.PAST_DUE - UNPAID -> Value.UNPAID - CANCELED -> Value.CANCELED - INCOMPLETE -> Value.INCOMPLETE - INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED - TRIALING -> Value.TRIALING - PAUSED -> Value.PAUSED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - PAST_DUE -> Known.PAST_DUE - UNPAID -> Known.UNPAID - CANCELED -> Known.CANCELED - INCOMPLETE -> Known.INCOMPLETE - INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED - TRIALING -> Known.TRIALING - PAUSED -> Known.PAUSED - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = MonthlyUsage.Builder::class) - @NoAutoDetect - class MonthlyUsage - private constructor( - private val monthYear: JsonField, - private val predictionCount: JsonField, - private val executionTimeMs: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun monthYear(): Optional = - Optional.ofNullable(monthYear.getNullable("monthYear")) - - fun predictionCount(): Optional = - Optional.ofNullable(predictionCount.getNullable("predictionCount")) - - fun executionTimeMs(): Optional = - Optional.ofNullable(executionTimeMs.getNullable("executionTimeMs")) - - @JsonProperty("monthYear") @ExcludeMissing fun _monthYear() = monthYear - - @JsonProperty("predictionCount") - @ExcludeMissing - fun _predictionCount() = predictionCount - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun _executionTimeMs() = executionTimeMs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MonthlyUsage = apply { - if (!validated) { - monthYear() - predictionCount() - executionTimeMs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var monthYear: JsonField = JsonMissing.of() - private var predictionCount: JsonField = JsonMissing.of() - private var executionTimeMs: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monthlyUsage: MonthlyUsage) = apply { - this.monthYear = monthlyUsage.monthYear - this.predictionCount = monthlyUsage.predictionCount - this.executionTimeMs = monthlyUsage.executionTimeMs - additionalProperties(monthlyUsage.additionalProperties) - } - - fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) - - @JsonProperty("monthYear") - @ExcludeMissing - fun monthYear(monthYear: JsonField) = apply { - this.monthYear = monthYear - } - - fun predictionCount(predictionCount: Long) = - predictionCount(JsonField.of(predictionCount)) - - @JsonProperty("predictionCount") - @ExcludeMissing - fun predictionCount(predictionCount: JsonField) = apply { - this.predictionCount = predictionCount - } - - fun executionTimeMs(executionTimeMs: Long) = - executionTimeMs(JsonField.of(executionTimeMs)) - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun executionTimeMs(executionTimeMs: JsonField) = apply { - this.executionTimeMs = executionTimeMs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MonthlyUsage = - MonthlyUsage( - monthYear, - predictionCount, - executionTimeMs, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonthlyUsage && monthYear == other.monthYear && predictionCount == other.predictionCount && executionTimeMs == other.executionTimeMs && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(monthYear, predictionCount, executionTimeMs, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonthlyUsage{monthYear=$monthYear, predictionCount=$predictionCount, executionTimeMs=$executionTimeMs, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Workspace && id == other.id && name == other.name && slug == other.slug && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && creatorId == other.creatorId && inviteCode == other.inviteCode && wildcardDomains == other.wildcardDomains && projectCount == other.projectCount && memberCount == other.memberCount && monthlyUsage == other.monthlyUsage && inviteCount == other.inviteCount && periodStartDate == other.periodStartDate && periodEndDate == other.periodEndDate && samlOnlyAccess == other.samlOnlyAccess && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, slug, dateCreated, dateUpdated, creatorId, inviteCode, wildcardDomains, projectCount, memberCount, monthlyUsage, inviteCount, periodStartDate, periodEndDate, samlOnlyAccess, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Workspace{id=$id, name=$name, slug=$slug, dateCreated=$dateCreated, dateUpdated=$dateUpdated, creatorId=$creatorId, inviteCode=$inviteCode, wildcardDomains=$wildcardDomains, projectCount=$projectCount, memberCount=$memberCount, monthlyUsage=$monthlyUsage, inviteCount=$inviteCount, periodStartDate=$periodStartDate, periodEndDate=$periodEndDate, samlOnlyAccess=$samlOnlyAccess, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InferencePipelineUpdateResponse && id == other.id && projectId == other.projectId && workspaceId == other.workspaceId && project == other.project && workspace == other.workspace && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && dateLastSampleReceived == other.dateLastSampleReceived && description == other.description && dateLastEvaluated == other.dateLastEvaluated && dateOfNextEvaluation == other.dateOfNextEvaluation && passingGoalCount == other.passingGoalCount && failingGoalCount == other.failingGoalCount && totalGoalCount == other.totalGoalCount && status == other.status && statusMessage == other.statusMessage && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, workspaceId, project, workspace, name, dateCreated, dateUpdated, dateLastSampleReceived, description, dateLastEvaluated, dateOfNextEvaluation, passingGoalCount, failingGoalCount, totalGoalCount, status, statusMessage, links, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InferencePipelineUpdateResponse{id=$id, projectId=$projectId, workspaceId=$workspaceId, project=$project, workspace=$workspace, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateLastSampleReceived=$dateLastSampleReceived, description=$description, dateLastEvaluated=$dateLastEvaluated, dateOfNextEvaluation=$dateOfNextEvaluation, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, status=$status, statusMessage=$statusMessage, links=$links, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt deleted file mode 100644 index ebdccfca..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt +++ /dev/null @@ -1,730 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -class ProjectCommitCreateParams -constructor( - private val projectId: String, - private val commit: Commit, - private val storageUri: String, - private val archived: Boolean?, - private val deploymentStatus: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun projectId(): String = projectId - - fun commit(): Commit = commit - - fun storageUri(): String = storageUri - - fun archived(): Optional = Optional.ofNullable(archived) - - fun deploymentStatus(): Optional = Optional.ofNullable(deploymentStatus) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectCommitCreateBody { - return ProjectCommitCreateBody( - commit, - storageUri, - archived, - deploymentStatus, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } - } - - @JsonDeserialize(builder = ProjectCommitCreateBody.Builder::class) - @NoAutoDetect - class ProjectCommitCreateBody - internal constructor( - private val commit: Commit?, - private val storageUri: String?, - private val archived: Boolean?, - private val deploymentStatus: String?, - private val additionalProperties: Map, - ) { - - /** The details of a commit (project version). */ - @JsonProperty("commit") fun commit(): Commit? = commit - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") fun storageUri(): String? = storageUri - - /** Whether the commit is archived. */ - @JsonProperty("archived") fun archived(): Boolean? = archived - - /** The deployment status associated with the commit's model. */ - @JsonProperty("deploymentStatus") fun deploymentStatus(): String? = deploymentStatus - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var commit: Commit? = null - private var storageUri: String? = null - private var archived: Boolean? = null - private var deploymentStatus: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectCommitCreateBody: ProjectCommitCreateBody) = apply { - this.commit = projectCommitCreateBody.commit - this.storageUri = projectCommitCreateBody.storageUri - this.archived = projectCommitCreateBody.archived - this.deploymentStatus = projectCommitCreateBody.deploymentStatus - additionalProperties(projectCommitCreateBody.additionalProperties) - } - - /** The details of a commit (project version). */ - @JsonProperty("commit") fun commit(commit: Commit) = apply { this.commit = commit } - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") - fun storageUri(storageUri: String) = apply { this.storageUri = storageUri } - - /** Whether the commit is archived. */ - @JsonProperty("archived") - fun archived(archived: Boolean) = apply { this.archived = archived } - - /** The deployment status associated with the commit's model. */ - @JsonProperty("deploymentStatus") - fun deploymentStatus(deploymentStatus: String) = apply { - this.deploymentStatus = deploymentStatus - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectCommitCreateBody = - ProjectCommitCreateBody( - checkNotNull(commit) { "`commit` is required but was not set" }, - checkNotNull(storageUri) { "`storageUri` is required but was not set" }, - archived, - deploymentStatus, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCommitCreateBody && commit == other.commit && storageUri == other.storageUri && archived == other.archived && deploymentStatus == other.deploymentStatus && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(commit, storageUri, archived, deploymentStatus, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectCommitCreateBody{commit=$commit, storageUri=$storageUri, archived=$archived, deploymentStatus=$deploymentStatus, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var projectId: String? = null - private var commit: Commit? = null - private var storageUri: String? = null - private var archived: Boolean? = null - private var deploymentStatus: 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(projectCommitCreateParams: ProjectCommitCreateParams) = apply { - projectId = projectCommitCreateParams.projectId - commit = projectCommitCreateParams.commit - storageUri = projectCommitCreateParams.storageUri - archived = projectCommitCreateParams.archived - deploymentStatus = projectCommitCreateParams.deploymentStatus - additionalHeaders = projectCommitCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectCommitCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectCommitCreateParams.additionalBodyProperties.toMutableMap() - } - - fun projectId(projectId: String) = apply { this.projectId = projectId } - - /** The details of a commit (project version). */ - fun commit(commit: Commit) = apply { this.commit = commit } - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(storageUri: String) = apply { this.storageUri = storageUri } - - /** Whether the commit is archived. */ - fun archived(archived: Boolean) = apply { this.archived = archived } - - /** The deployment status associated with the commit's model. */ - fun deploymentStatus(deploymentStatus: String) = apply { - this.deploymentStatus = deploymentStatus - } - - 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) - } - - fun build(): ProjectCommitCreateParams = - ProjectCommitCreateParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(commit) { "`commit` is required but was not set" }, - checkNotNull(storageUri) { "`storageUri` is required but was not set" }, - archived, - deploymentStatus, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - /** The details of a commit (project version). */ - @JsonDeserialize(builder = Commit.Builder::class) - @NoAutoDetect - class Commit - private constructor( - private val id: String?, - private val authorId: String?, - private val dateCreated: OffsetDateTime?, - private val fileSize: Long?, - private val message: String?, - private val mlModelId: String?, - private val validationDatasetId: String?, - private val trainingDatasetId: String?, - private val storageUri: String?, - private val gitCommitSha: Long?, - private val gitCommitRef: String?, - private val gitCommitUrl: String?, - private val additionalProperties: Map, - ) { - - /** The commit id. */ - @JsonProperty("id") fun id(): String? = id - - /** The author id of the commit. */ - @JsonProperty("authorId") fun authorId(): String? = authorId - - /** The commit creation date. */ - @JsonProperty("dateCreated") fun dateCreated(): OffsetDateTime? = dateCreated - - /** The size of the commit bundle in bytes. */ - @JsonProperty("fileSize") fun fileSize(): Long? = fileSize - - /** The commit message. */ - @JsonProperty("message") fun message(): String? = message - - /** The model id. */ - @JsonProperty("mlModelId") fun mlModelId(): String? = mlModelId - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - fun validationDatasetId(): String? = validationDatasetId - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") fun trainingDatasetId(): String? = trainingDatasetId - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") fun storageUri(): String? = storageUri - - /** The SHA of the corresponding git commit. */ - @JsonProperty("gitCommitSha") fun gitCommitSha(): Long? = gitCommitSha - - /** The ref of the corresponding git commit. */ - @JsonProperty("gitCommitRef") fun gitCommitRef(): String? = gitCommitRef - - /** The URL of the corresponding git commit. */ - @JsonProperty("gitCommitUrl") fun gitCommitUrl(): String? = gitCommitUrl - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var authorId: String? = null - private var dateCreated: OffsetDateTime? = null - private var fileSize: Long? = null - private var message: String? = null - private var mlModelId: String? = null - private var validationDatasetId: String? = null - private var trainingDatasetId: String? = null - private var storageUri: String? = null - private var gitCommitSha: Long? = null - private var gitCommitRef: String? = null - private var gitCommitUrl: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commit: Commit) = apply { - this.id = commit.id - this.authorId = commit.authorId - this.dateCreated = commit.dateCreated - this.fileSize = commit.fileSize - this.message = commit.message - this.mlModelId = commit.mlModelId - this.validationDatasetId = commit.validationDatasetId - this.trainingDatasetId = commit.trainingDatasetId - this.storageUri = commit.storageUri - this.gitCommitSha = commit.gitCommitSha - this.gitCommitRef = commit.gitCommitRef - this.gitCommitUrl = commit.gitCommitUrl - additionalProperties(commit.additionalProperties) - } - - /** The commit id. */ - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - /** The author id of the commit. */ - @JsonProperty("authorId") - fun authorId(authorId: String) = apply { this.authorId = authorId } - - /** The commit creation date. */ - @JsonProperty("dateCreated") - fun dateCreated(dateCreated: OffsetDateTime) = apply { this.dateCreated = dateCreated } - - /** The size of the commit bundle in bytes. */ - @JsonProperty("fileSize") - fun fileSize(fileSize: Long) = apply { this.fileSize = fileSize } - - /** The commit message. */ - @JsonProperty("message") fun message(message: String) = apply { this.message = message } - - /** The model id. */ - @JsonProperty("mlModelId") - fun mlModelId(mlModelId: String) = apply { this.mlModelId = mlModelId } - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - fun validationDatasetId(validationDatasetId: String) = apply { - this.validationDatasetId = validationDatasetId - } - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - fun trainingDatasetId(trainingDatasetId: String) = apply { - this.trainingDatasetId = trainingDatasetId - } - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") - fun storageUri(storageUri: String) = apply { this.storageUri = storageUri } - - /** The SHA of the corresponding git commit. */ - @JsonProperty("gitCommitSha") - fun gitCommitSha(gitCommitSha: Long) = apply { this.gitCommitSha = gitCommitSha } - - /** The ref of the corresponding git commit. */ - @JsonProperty("gitCommitRef") - fun gitCommitRef(gitCommitRef: String) = apply { this.gitCommitRef = gitCommitRef } - - /** The URL of the corresponding git commit. */ - @JsonProperty("gitCommitUrl") - fun gitCommitUrl(gitCommitUrl: String) = apply { this.gitCommitUrl = gitCommitUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Commit = - Commit( - checkNotNull(id) { "`id` is required but was not set" }, - checkNotNull(authorId) { "`authorId` is required but was not set" }, - dateCreated, - fileSize, - checkNotNull(message) { "`message` is required but was not set" }, - mlModelId, - validationDatasetId, - trainingDatasetId, - checkNotNull(storageUri) { "`storageUri` is required but was not set" }, - gitCommitSha, - gitCommitRef, - gitCommitUrl, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && dateCreated == other.dateCreated && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && validationDatasetId == other.validationDatasetId && trainingDatasetId == other.trainingDatasetId && storageUri == other.storageUri && gitCommitSha == other.gitCommitSha && gitCommitRef == other.gitCommitRef && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, authorId, dateCreated, fileSize, message, mlModelId, validationDatasetId, trainingDatasetId, storageUri, gitCommitSha, gitCommitRef, gitCommitUrl, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Commit{id=$id, authorId=$authorId, dateCreated=$dateCreated, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, storageUri=$storageUri, gitCommitSha=$gitCommitSha, gitCommitRef=$gitCommitRef, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: String?, - private val additionalProperties: Map, - ) { - - @JsonProperty("app") fun app(): String? = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - @JsonProperty("app") fun app(app: String) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = - Links( - checkNotNull(app) { "`app` is required but was not set" }, - additionalProperties.toImmutable() - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCommitCreateParams && projectId == other.projectId && commit == other.commit && storageUri == other.storageUri && archived == other.archived && deploymentStatus == other.deploymentStatus && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, commit, storageUri, archived, deploymentStatus, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectCommitCreateParams{projectId=$projectId, commit=$commit, storageUri=$storageUri, archived=$archived, deploymentStatus=$deploymentStatus, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt deleted file mode 100644 index 70d132a7..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt +++ /dev/null @@ -1,942 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = ProjectCommitCreateResponse.Builder::class) -@NoAutoDetect -class ProjectCommitCreateResponse -private constructor( - private val id: JsonField, - private val dateCreated: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val projectId: JsonField, - private val storageUri: JsonField, - private val commit: JsonField, - private val deploymentStatus: JsonField, - private val mlModelId: JsonField, - private val validationDatasetId: JsonField, - private val trainingDatasetId: JsonField, - private val archived: JsonField, - private val dateArchived: JsonField, - private val passingGoalCount: JsonField, - private val failingGoalCount: JsonField, - private val totalGoalCount: JsonField, - private val links: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The project version (commit) id. */ - fun id(): String = id.getRequired("id") - - /** The project version (commit) creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - fun status(): Status = status.getRequired("status") - - /** The commit status message. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - /** The project id. */ - fun projectId(): String = projectId.getRequired("projectId") - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(): String = storageUri.getRequired("storageUri") - - /** The details of a commit (project version). */ - fun commit(): Commit = commit.getRequired("commit") - - /** The deployment status associated with the commit's model. */ - fun deploymentStatus(): Optional = - Optional.ofNullable(deploymentStatus.getNullable("deploymentStatus")) - - /** The model id. */ - fun mlModelId(): Optional = Optional.ofNullable(mlModelId.getNullable("mlModelId")) - - /** The validation dataset id. */ - fun validationDatasetId(): Optional = - Optional.ofNullable(validationDatasetId.getNullable("validationDatasetId")) - - /** The training dataset id. */ - fun trainingDatasetId(): Optional = - Optional.ofNullable(trainingDatasetId.getNullable("trainingDatasetId")) - - /** Whether the commit is archived. */ - fun archived(): Optional = Optional.ofNullable(archived.getNullable("archived")) - - /** The commit archive date. */ - fun dateArchived(): Optional = - Optional.ofNullable(dateArchived.getNullable("dateArchived")) - - /** The number of tests that are passing for the commit. */ - fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") - - /** The number of tests that are failing for the commit. */ - fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") - - /** The total number of tests for the commit. */ - fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") - - fun links(): Optional = Optional.ofNullable(links.getNullable("links")) - - /** The project version (commit) id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The project version (commit) creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The commit status message. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - /** The project id. */ - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri - - /** The details of a commit (project version). */ - @JsonProperty("commit") @ExcludeMissing fun _commit() = commit - - /** The deployment status associated with the commit's model. */ - @JsonProperty("deploymentStatus") @ExcludeMissing fun _deploymentStatus() = deploymentStatus - - /** The model id. */ - @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId() = mlModelId - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun _validationDatasetId() = validationDatasetId - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") @ExcludeMissing fun _trainingDatasetId() = trainingDatasetId - - /** Whether the commit is archived. */ - @JsonProperty("archived") @ExcludeMissing fun _archived() = archived - - /** The commit archive date. */ - @JsonProperty("dateArchived") @ExcludeMissing fun _dateArchived() = dateArchived - - /** The number of tests that are passing for the commit. */ - @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount - - /** The number of tests that are failing for the commit. */ - @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount - - /** The total number of tests for the commit. */ - @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount - - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectCommitCreateResponse = apply { - if (!validated) { - id() - dateCreated() - status() - statusMessage() - projectId() - storageUri() - commit().validate() - deploymentStatus() - mlModelId() - validationDatasetId() - trainingDatasetId() - archived() - dateArchived() - passingGoalCount() - failingGoalCount() - totalGoalCount() - links().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var storageUri: JsonField = JsonMissing.of() - private var commit: JsonField = JsonMissing.of() - private var deploymentStatus: JsonField = JsonMissing.of() - private var mlModelId: JsonField = JsonMissing.of() - private var validationDatasetId: JsonField = JsonMissing.of() - private var trainingDatasetId: JsonField = JsonMissing.of() - private var archived: JsonField = JsonMissing.of() - private var dateArchived: JsonField = JsonMissing.of() - private var passingGoalCount: JsonField = JsonMissing.of() - private var failingGoalCount: JsonField = JsonMissing.of() - private var totalGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectCommitCreateResponse: ProjectCommitCreateResponse) = apply { - this.id = projectCommitCreateResponse.id - this.dateCreated = projectCommitCreateResponse.dateCreated - this.status = projectCommitCreateResponse.status - this.statusMessage = projectCommitCreateResponse.statusMessage - this.projectId = projectCommitCreateResponse.projectId - this.storageUri = projectCommitCreateResponse.storageUri - this.commit = projectCommitCreateResponse.commit - this.deploymentStatus = projectCommitCreateResponse.deploymentStatus - this.mlModelId = projectCommitCreateResponse.mlModelId - this.validationDatasetId = projectCommitCreateResponse.validationDatasetId - this.trainingDatasetId = projectCommitCreateResponse.trainingDatasetId - this.archived = projectCommitCreateResponse.archived - this.dateArchived = projectCommitCreateResponse.dateArchived - this.passingGoalCount = projectCommitCreateResponse.passingGoalCount - this.failingGoalCount = projectCommitCreateResponse.failingGoalCount - this.totalGoalCount = projectCommitCreateResponse.totalGoalCount - this.links = projectCommitCreateResponse.links - additionalProperties(projectCommitCreateResponse.additionalProperties) - } - - /** The project version (commit) id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project version (commit) id. */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The project version (commit) creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project version (commit) creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The commit status message. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The commit status message. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - /** The project id. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** The project id. */ - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") - @ExcludeMissing - fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } - - /** The details of a commit (project version). */ - fun commit(commit: Commit) = commit(JsonField.of(commit)) - - /** The details of a commit (project version). */ - @JsonProperty("commit") - @ExcludeMissing - fun commit(commit: JsonField) = apply { this.commit = commit } - - /** The deployment status associated with the commit's model. */ - fun deploymentStatus(deploymentStatus: String) = - deploymentStatus(JsonField.of(deploymentStatus)) - - /** The deployment status associated with the commit's model. */ - @JsonProperty("deploymentStatus") - @ExcludeMissing - fun deploymentStatus(deploymentStatus: JsonField) = apply { - this.deploymentStatus = deploymentStatus - } - - /** The model id. */ - fun mlModelId(mlModelId: String) = mlModelId(JsonField.of(mlModelId)) - - /** The model id. */ - @JsonProperty("mlModelId") - @ExcludeMissing - fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } - - /** The validation dataset id. */ - fun validationDatasetId(validationDatasetId: String) = - validationDatasetId(JsonField.of(validationDatasetId)) - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun validationDatasetId(validationDatasetId: JsonField) = apply { - this.validationDatasetId = validationDatasetId - } - - /** The training dataset id. */ - fun trainingDatasetId(trainingDatasetId: String) = - trainingDatasetId(JsonField.of(trainingDatasetId)) - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun trainingDatasetId(trainingDatasetId: JsonField) = apply { - this.trainingDatasetId = trainingDatasetId - } - - /** Whether the commit is archived. */ - fun archived(archived: Boolean) = archived(JsonField.of(archived)) - - /** Whether the commit is archived. */ - @JsonProperty("archived") - @ExcludeMissing - fun archived(archived: JsonField) = apply { this.archived = archived } - - /** The commit archive date. */ - fun dateArchived(dateArchived: OffsetDateTime) = dateArchived(JsonField.of(dateArchived)) - - /** The commit archive date. */ - @JsonProperty("dateArchived") - @ExcludeMissing - fun dateArchived(dateArchived: JsonField) = apply { - this.dateArchived = dateArchived - } - - /** The number of tests that are passing for the commit. */ - fun passingGoalCount(passingGoalCount: Long) = - passingGoalCount(JsonField.of(passingGoalCount)) - - /** The number of tests that are passing for the commit. */ - @JsonProperty("passingGoalCount") - @ExcludeMissing - fun passingGoalCount(passingGoalCount: JsonField) = apply { - this.passingGoalCount = passingGoalCount - } - - /** The number of tests that are failing for the commit. */ - fun failingGoalCount(failingGoalCount: Long) = - failingGoalCount(JsonField.of(failingGoalCount)) - - /** The number of tests that are failing for the commit. */ - @JsonProperty("failingGoalCount") - @ExcludeMissing - fun failingGoalCount(failingGoalCount: JsonField) = apply { - this.failingGoalCount = failingGoalCount - } - - /** The total number of tests for the commit. */ - fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) - - /** The total number of tests for the commit. */ - @JsonProperty("totalGoalCount") - @ExcludeMissing - fun totalGoalCount(totalGoalCount: JsonField) = apply { - this.totalGoalCount = totalGoalCount - } - - fun links(links: Links) = links(JsonField.of(links)) - - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectCommitCreateResponse = - ProjectCommitCreateResponse( - id, - dateCreated, - status, - statusMessage, - projectId, - storageUri, - commit, - deploymentStatus, - mlModelId, - validationDatasetId, - trainingDatasetId, - archived, - dateArchived, - passingGoalCount, - failingGoalCount, - totalGoalCount, - links, - additionalProperties.toImmutable(), - ) - } - - /** The details of a commit (project version). */ - @JsonDeserialize(builder = Commit.Builder::class) - @NoAutoDetect - class Commit - private constructor( - private val id: JsonField, - private val authorId: JsonField, - private val dateCreated: JsonField, - private val fileSize: JsonField, - private val message: JsonField, - private val mlModelId: JsonField, - private val validationDatasetId: JsonField, - private val trainingDatasetId: JsonField, - private val storageUri: JsonField, - private val gitCommitSha: JsonField, - private val gitCommitRef: JsonField, - private val gitCommitUrl: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The commit id. */ - fun id(): String = id.getRequired("id") - - /** The author id of the commit. */ - fun authorId(): String = authorId.getRequired("authorId") - - /** The commit creation date. */ - fun dateCreated(): Optional = - Optional.ofNullable(dateCreated.getNullable("dateCreated")) - - /** The size of the commit bundle in bytes. */ - fun fileSize(): Optional = Optional.ofNullable(fileSize.getNullable("fileSize")) - - /** The commit message. */ - fun message(): String = message.getRequired("message") - - /** The model id. */ - fun mlModelId(): Optional = Optional.ofNullable(mlModelId.getNullable("mlModelId")) - - /** The validation dataset id. */ - fun validationDatasetId(): Optional = - Optional.ofNullable(validationDatasetId.getNullable("validationDatasetId")) - - /** The training dataset id. */ - fun trainingDatasetId(): Optional = - Optional.ofNullable(trainingDatasetId.getNullable("trainingDatasetId")) - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(): String = storageUri.getRequired("storageUri") - - /** The SHA of the corresponding git commit. */ - fun gitCommitSha(): Optional = - Optional.ofNullable(gitCommitSha.getNullable("gitCommitSha")) - - /** The ref of the corresponding git commit. */ - fun gitCommitRef(): Optional = - Optional.ofNullable(gitCommitRef.getNullable("gitCommitRef")) - - /** The URL of the corresponding git commit. */ - fun gitCommitUrl(): Optional = - Optional.ofNullable(gitCommitUrl.getNullable("gitCommitUrl")) - - /** The commit id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The author id of the commit. */ - @JsonProperty("authorId") @ExcludeMissing fun _authorId() = authorId - - /** The commit creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The size of the commit bundle in bytes. */ - @JsonProperty("fileSize") @ExcludeMissing fun _fileSize() = fileSize - - /** The commit message. */ - @JsonProperty("message") @ExcludeMissing fun _message() = message - - /** The model id. */ - @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId() = mlModelId - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun _validationDatasetId() = validationDatasetId - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun _trainingDatasetId() = trainingDatasetId - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri - - /** The SHA of the corresponding git commit. */ - @JsonProperty("gitCommitSha") @ExcludeMissing fun _gitCommitSha() = gitCommitSha - - /** The ref of the corresponding git commit. */ - @JsonProperty("gitCommitRef") @ExcludeMissing fun _gitCommitRef() = gitCommitRef - - /** The URL of the corresponding git commit. */ - @JsonProperty("gitCommitUrl") @ExcludeMissing fun _gitCommitUrl() = gitCommitUrl - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Commit = apply { - if (!validated) { - id() - authorId() - dateCreated() - fileSize() - message() - mlModelId() - validationDatasetId() - trainingDatasetId() - storageUri() - gitCommitSha() - gitCommitRef() - gitCommitUrl() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var authorId: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var fileSize: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var mlModelId: JsonField = JsonMissing.of() - private var validationDatasetId: JsonField = JsonMissing.of() - private var trainingDatasetId: JsonField = JsonMissing.of() - private var storageUri: JsonField = JsonMissing.of() - private var gitCommitSha: JsonField = JsonMissing.of() - private var gitCommitRef: JsonField = JsonMissing.of() - private var gitCommitUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commit: Commit) = apply { - this.id = commit.id - this.authorId = commit.authorId - this.dateCreated = commit.dateCreated - this.fileSize = commit.fileSize - this.message = commit.message - this.mlModelId = commit.mlModelId - this.validationDatasetId = commit.validationDatasetId - this.trainingDatasetId = commit.trainingDatasetId - this.storageUri = commit.storageUri - this.gitCommitSha = commit.gitCommitSha - this.gitCommitRef = commit.gitCommitRef - this.gitCommitUrl = commit.gitCommitUrl - additionalProperties(commit.additionalProperties) - } - - /** The commit id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The commit id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The author id of the commit. */ - fun authorId(authorId: String) = authorId(JsonField.of(authorId)) - - /** The author id of the commit. */ - @JsonProperty("authorId") - @ExcludeMissing - fun authorId(authorId: JsonField) = apply { this.authorId = authorId } - - /** The commit creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The commit creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The size of the commit bundle in bytes. */ - fun fileSize(fileSize: Long) = fileSize(JsonField.of(fileSize)) - - /** The size of the commit bundle in bytes. */ - @JsonProperty("fileSize") - @ExcludeMissing - fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } - - /** The commit message. */ - fun message(message: String) = message(JsonField.of(message)) - - /** The commit message. */ - @JsonProperty("message") - @ExcludeMissing - fun message(message: JsonField) = apply { this.message = message } - - /** The model id. */ - fun mlModelId(mlModelId: String) = mlModelId(JsonField.of(mlModelId)) - - /** The model id. */ - @JsonProperty("mlModelId") - @ExcludeMissing - fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } - - /** The validation dataset id. */ - fun validationDatasetId(validationDatasetId: String) = - validationDatasetId(JsonField.of(validationDatasetId)) - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun validationDatasetId(validationDatasetId: JsonField) = apply { - this.validationDatasetId = validationDatasetId - } - - /** The training dataset id. */ - fun trainingDatasetId(trainingDatasetId: String) = - trainingDatasetId(JsonField.of(trainingDatasetId)) - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun trainingDatasetId(trainingDatasetId: JsonField) = apply { - this.trainingDatasetId = trainingDatasetId - } - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") - @ExcludeMissing - fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } - - /** The SHA of the corresponding git commit. */ - fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) - - /** The SHA of the corresponding git commit. */ - @JsonProperty("gitCommitSha") - @ExcludeMissing - fun gitCommitSha(gitCommitSha: JsonField) = apply { - this.gitCommitSha = gitCommitSha - } - - /** The ref of the corresponding git commit. */ - fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) - - /** The ref of the corresponding git commit. */ - @JsonProperty("gitCommitRef") - @ExcludeMissing - fun gitCommitRef(gitCommitRef: JsonField) = apply { - this.gitCommitRef = gitCommitRef - } - - /** The URL of the corresponding git commit. */ - fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) - - /** The URL of the corresponding git commit. */ - @JsonProperty("gitCommitUrl") - @ExcludeMissing - fun gitCommitUrl(gitCommitUrl: JsonField) = apply { - this.gitCommitUrl = gitCommitUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Commit = - Commit( - id, - authorId, - dateCreated, - fileSize, - message, - mlModelId, - validationDatasetId, - trainingDatasetId, - storageUri, - gitCommitSha, - gitCommitRef, - gitCommitUrl, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && dateCreated == other.dateCreated && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && validationDatasetId == other.validationDatasetId && trainingDatasetId == other.trainingDatasetId && storageUri == other.storageUri && gitCommitSha == other.gitCommitSha && gitCommitRef == other.gitCommitRef && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, authorId, dateCreated, fileSize, message, mlModelId, validationDatasetId, trainingDatasetId, storageUri, gitCommitSha, gitCommitRef, gitCommitUrl, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Commit{id=$id, authorId=$authorId, dateCreated=$dateCreated, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, storageUri=$storageUri, gitCommitSha=$gitCommitSha, gitCommitRef=$gitCommitRef, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCommitCreateResponse && id == other.id && dateCreated == other.dateCreated && status == other.status && statusMessage == other.statusMessage && projectId == other.projectId && storageUri == other.storageUri && commit == other.commit && deploymentStatus == other.deploymentStatus && mlModelId == other.mlModelId && validationDatasetId == other.validationDatasetId && trainingDatasetId == other.trainingDatasetId && archived == other.archived && dateArchived == other.dateArchived && passingGoalCount == other.passingGoalCount && failingGoalCount == other.failingGoalCount && totalGoalCount == other.totalGoalCount && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, dateCreated, status, statusMessage, projectId, storageUri, commit, deploymentStatus, mlModelId, validationDatasetId, trainingDatasetId, archived, dateArchived, passingGoalCount, failingGoalCount, totalGoalCount, links, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectCommitCreateResponse{id=$id, dateCreated=$dateCreated, status=$status, statusMessage=$statusMessage, projectId=$projectId, storageUri=$storageUri, commit=$commit, deploymentStatus=$deploymentStatus, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, archived=$archived, dateArchived=$dateArchived, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, links=$links, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitListResponse.kt deleted file mode 100644 index 757b7f13..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitListResponse.kt +++ /dev/null @@ -1,1041 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = ProjectCommitListResponse.Builder::class) -@NoAutoDetect -class ProjectCommitListResponse -private constructor( - private val items: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun items(): List = items.getRequired("items") - - @JsonProperty("items") @ExcludeMissing fun _items() = items - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectCommitListResponse = apply { - if (!validated) { - items().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectCommitListResponse: ProjectCommitListResponse) = apply { - this.items = projectCommitListResponse.items - additionalProperties(projectCommitListResponse.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - @JsonProperty("items") - @ExcludeMissing - fun items(items: JsonField>) = apply { this.items = items } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectCommitListResponse = - ProjectCommitListResponse( - items.map { it.toImmutable() }, - additionalProperties.toImmutable() - ) - } - - @JsonDeserialize(builder = Item.Builder::class) - @NoAutoDetect - class Item - private constructor( - private val id: JsonField, - private val dateCreated: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val projectId: JsonField, - private val storageUri: JsonField, - private val commit: JsonField, - private val deploymentStatus: JsonField, - private val mlModelId: JsonField, - private val validationDatasetId: JsonField, - private val trainingDatasetId: JsonField, - private val archived: JsonField, - private val dateArchived: JsonField, - private val passingGoalCount: JsonField, - private val failingGoalCount: JsonField, - private val totalGoalCount: JsonField, - private val links: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The project version (commit) id. */ - fun id(): String = id.getRequired("id") - - /** The project version (commit) creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - fun status(): Status = status.getRequired("status") - - /** The commit status message. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - /** The project id. */ - fun projectId(): String = projectId.getRequired("projectId") - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(): String = storageUri.getRequired("storageUri") - - /** The details of a commit (project version). */ - fun commit(): Commit = commit.getRequired("commit") - - /** The deployment status associated with the commit's model. */ - fun deploymentStatus(): Optional = - Optional.ofNullable(deploymentStatus.getNullable("deploymentStatus")) - - /** The model id. */ - fun mlModelId(): Optional = Optional.ofNullable(mlModelId.getNullable("mlModelId")) - - /** The validation dataset id. */ - fun validationDatasetId(): Optional = - Optional.ofNullable(validationDatasetId.getNullable("validationDatasetId")) - - /** The training dataset id. */ - fun trainingDatasetId(): Optional = - Optional.ofNullable(trainingDatasetId.getNullable("trainingDatasetId")) - - /** Whether the commit is archived. */ - fun archived(): Optional = Optional.ofNullable(archived.getNullable("archived")) - - /** The commit archive date. */ - fun dateArchived(): Optional = - Optional.ofNullable(dateArchived.getNullable("dateArchived")) - - /** The number of tests that are passing for the commit. */ - fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") - - /** The number of tests that are failing for the commit. */ - fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") - - /** The total number of tests for the commit. */ - fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") - - fun links(): Optional = Optional.ofNullable(links.getNullable("links")) - - /** The project version (commit) id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The project version (commit) creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The commit status message. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - /** The project id. */ - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri - - /** The details of a commit (project version). */ - @JsonProperty("commit") @ExcludeMissing fun _commit() = commit - - /** The deployment status associated with the commit's model. */ - @JsonProperty("deploymentStatus") @ExcludeMissing fun _deploymentStatus() = deploymentStatus - - /** The model id. */ - @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId() = mlModelId - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun _validationDatasetId() = validationDatasetId - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun _trainingDatasetId() = trainingDatasetId - - /** Whether the commit is archived. */ - @JsonProperty("archived") @ExcludeMissing fun _archived() = archived - - /** The commit archive date. */ - @JsonProperty("dateArchived") @ExcludeMissing fun _dateArchived() = dateArchived - - /** The number of tests that are passing for the commit. */ - @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount - - /** The number of tests that are failing for the commit. */ - @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount - - /** The total number of tests for the commit. */ - @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount - - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Item = apply { - if (!validated) { - id() - dateCreated() - status() - statusMessage() - projectId() - storageUri() - commit().validate() - deploymentStatus() - mlModelId() - validationDatasetId() - trainingDatasetId() - archived() - dateArchived() - passingGoalCount() - failingGoalCount() - totalGoalCount() - links().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var storageUri: JsonField = JsonMissing.of() - private var commit: JsonField = JsonMissing.of() - private var deploymentStatus: JsonField = JsonMissing.of() - private var mlModelId: JsonField = JsonMissing.of() - private var validationDatasetId: JsonField = JsonMissing.of() - private var trainingDatasetId: JsonField = JsonMissing.of() - private var archived: JsonField = JsonMissing.of() - private var dateArchived: JsonField = JsonMissing.of() - private var passingGoalCount: JsonField = JsonMissing.of() - private var failingGoalCount: JsonField = JsonMissing.of() - private var totalGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - this.id = item.id - this.dateCreated = item.dateCreated - this.status = item.status - this.statusMessage = item.statusMessage - this.projectId = item.projectId - this.storageUri = item.storageUri - this.commit = item.commit - this.deploymentStatus = item.deploymentStatus - this.mlModelId = item.mlModelId - this.validationDatasetId = item.validationDatasetId - this.trainingDatasetId = item.trainingDatasetId - this.archived = item.archived - this.dateArchived = item.dateArchived - this.passingGoalCount = item.passingGoalCount - this.failingGoalCount = item.failingGoalCount - this.totalGoalCount = item.totalGoalCount - this.links = item.links - additionalProperties(item.additionalProperties) - } - - /** The project version (commit) id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project version (commit) id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The project version (commit) creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project version (commit) creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * The commit status. Initially, the commit is `queued`, then, it switches to `running`. - * Finally, it can be `paused`, `failed`, or `completed`. - */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The commit status message. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The commit status message. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - /** The project id. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** The project id. */ - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") - @ExcludeMissing - fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } - - /** The details of a commit (project version). */ - fun commit(commit: Commit) = commit(JsonField.of(commit)) - - /** The details of a commit (project version). */ - @JsonProperty("commit") - @ExcludeMissing - fun commit(commit: JsonField) = apply { this.commit = commit } - - /** The deployment status associated with the commit's model. */ - fun deploymentStatus(deploymentStatus: String) = - deploymentStatus(JsonField.of(deploymentStatus)) - - /** The deployment status associated with the commit's model. */ - @JsonProperty("deploymentStatus") - @ExcludeMissing - fun deploymentStatus(deploymentStatus: JsonField) = apply { - this.deploymentStatus = deploymentStatus - } - - /** The model id. */ - fun mlModelId(mlModelId: String) = mlModelId(JsonField.of(mlModelId)) - - /** The model id. */ - @JsonProperty("mlModelId") - @ExcludeMissing - fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } - - /** The validation dataset id. */ - fun validationDatasetId(validationDatasetId: String) = - validationDatasetId(JsonField.of(validationDatasetId)) - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun validationDatasetId(validationDatasetId: JsonField) = apply { - this.validationDatasetId = validationDatasetId - } - - /** The training dataset id. */ - fun trainingDatasetId(trainingDatasetId: String) = - trainingDatasetId(JsonField.of(trainingDatasetId)) - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun trainingDatasetId(trainingDatasetId: JsonField) = apply { - this.trainingDatasetId = trainingDatasetId - } - - /** Whether the commit is archived. */ - fun archived(archived: Boolean) = archived(JsonField.of(archived)) - - /** Whether the commit is archived. */ - @JsonProperty("archived") - @ExcludeMissing - fun archived(archived: JsonField) = apply { this.archived = archived } - - /** The commit archive date. */ - fun dateArchived(dateArchived: OffsetDateTime) = - dateArchived(JsonField.of(dateArchived)) - - /** The commit archive date. */ - @JsonProperty("dateArchived") - @ExcludeMissing - fun dateArchived(dateArchived: JsonField) = apply { - this.dateArchived = dateArchived - } - - /** The number of tests that are passing for the commit. */ - fun passingGoalCount(passingGoalCount: Long) = - passingGoalCount(JsonField.of(passingGoalCount)) - - /** The number of tests that are passing for the commit. */ - @JsonProperty("passingGoalCount") - @ExcludeMissing - fun passingGoalCount(passingGoalCount: JsonField) = apply { - this.passingGoalCount = passingGoalCount - } - - /** The number of tests that are failing for the commit. */ - fun failingGoalCount(failingGoalCount: Long) = - failingGoalCount(JsonField.of(failingGoalCount)) - - /** The number of tests that are failing for the commit. */ - @JsonProperty("failingGoalCount") - @ExcludeMissing - fun failingGoalCount(failingGoalCount: JsonField) = apply { - this.failingGoalCount = failingGoalCount - } - - /** The total number of tests for the commit. */ - fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) - - /** The total number of tests for the commit. */ - @JsonProperty("totalGoalCount") - @ExcludeMissing - fun totalGoalCount(totalGoalCount: JsonField) = apply { - this.totalGoalCount = totalGoalCount - } - - fun links(links: Links) = links(JsonField.of(links)) - - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Item = - Item( - id, - dateCreated, - status, - statusMessage, - projectId, - storageUri, - commit, - deploymentStatus, - mlModelId, - validationDatasetId, - trainingDatasetId, - archived, - dateArchived, - passingGoalCount, - failingGoalCount, - totalGoalCount, - links, - additionalProperties.toImmutable(), - ) - } - - /** The details of a commit (project version). */ - @JsonDeserialize(builder = Commit.Builder::class) - @NoAutoDetect - class Commit - private constructor( - private val id: JsonField, - private val authorId: JsonField, - private val dateCreated: JsonField, - private val fileSize: JsonField, - private val message: JsonField, - private val mlModelId: JsonField, - private val validationDatasetId: JsonField, - private val trainingDatasetId: JsonField, - private val storageUri: JsonField, - private val gitCommitSha: JsonField, - private val gitCommitRef: JsonField, - private val gitCommitUrl: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The commit id. */ - fun id(): String = id.getRequired("id") - - /** The author id of the commit. */ - fun authorId(): String = authorId.getRequired("authorId") - - /** The commit creation date. */ - fun dateCreated(): Optional = - Optional.ofNullable(dateCreated.getNullable("dateCreated")) - - /** The size of the commit bundle in bytes. */ - fun fileSize(): Optional = Optional.ofNullable(fileSize.getNullable("fileSize")) - - /** The commit message. */ - fun message(): String = message.getRequired("message") - - /** The model id. */ - fun mlModelId(): Optional = - Optional.ofNullable(mlModelId.getNullable("mlModelId")) - - /** The validation dataset id. */ - fun validationDatasetId(): Optional = - Optional.ofNullable(validationDatasetId.getNullable("validationDatasetId")) - - /** The training dataset id. */ - fun trainingDatasetId(): Optional = - Optional.ofNullable(trainingDatasetId.getNullable("trainingDatasetId")) - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(): String = storageUri.getRequired("storageUri") - - /** The SHA of the corresponding git commit. */ - fun gitCommitSha(): Optional = - Optional.ofNullable(gitCommitSha.getNullable("gitCommitSha")) - - /** The ref of the corresponding git commit. */ - fun gitCommitRef(): Optional = - Optional.ofNullable(gitCommitRef.getNullable("gitCommitRef")) - - /** The URL of the corresponding git commit. */ - fun gitCommitUrl(): Optional = - Optional.ofNullable(gitCommitUrl.getNullable("gitCommitUrl")) - - /** The commit id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The author id of the commit. */ - @JsonProperty("authorId") @ExcludeMissing fun _authorId() = authorId - - /** The commit creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The size of the commit bundle in bytes. */ - @JsonProperty("fileSize") @ExcludeMissing fun _fileSize() = fileSize - - /** The commit message. */ - @JsonProperty("message") @ExcludeMissing fun _message() = message - - /** The model id. */ - @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId() = mlModelId - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun _validationDatasetId() = validationDatasetId - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun _trainingDatasetId() = trainingDatasetId - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri - - /** The SHA of the corresponding git commit. */ - @JsonProperty("gitCommitSha") @ExcludeMissing fun _gitCommitSha() = gitCommitSha - - /** The ref of the corresponding git commit. */ - @JsonProperty("gitCommitRef") @ExcludeMissing fun _gitCommitRef() = gitCommitRef - - /** The URL of the corresponding git commit. */ - @JsonProperty("gitCommitUrl") @ExcludeMissing fun _gitCommitUrl() = gitCommitUrl - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Commit = apply { - if (!validated) { - id() - authorId() - dateCreated() - fileSize() - message() - mlModelId() - validationDatasetId() - trainingDatasetId() - storageUri() - gitCommitSha() - gitCommitRef() - gitCommitUrl() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var authorId: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var fileSize: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var mlModelId: JsonField = JsonMissing.of() - private var validationDatasetId: JsonField = JsonMissing.of() - private var trainingDatasetId: JsonField = JsonMissing.of() - private var storageUri: JsonField = JsonMissing.of() - private var gitCommitSha: JsonField = JsonMissing.of() - private var gitCommitRef: JsonField = JsonMissing.of() - private var gitCommitUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(commit: Commit) = apply { - this.id = commit.id - this.authorId = commit.authorId - this.dateCreated = commit.dateCreated - this.fileSize = commit.fileSize - this.message = commit.message - this.mlModelId = commit.mlModelId - this.validationDatasetId = commit.validationDatasetId - this.trainingDatasetId = commit.trainingDatasetId - this.storageUri = commit.storageUri - this.gitCommitSha = commit.gitCommitSha - this.gitCommitRef = commit.gitCommitRef - this.gitCommitUrl = commit.gitCommitUrl - additionalProperties(commit.additionalProperties) - } - - /** The commit id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The commit id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The author id of the commit. */ - fun authorId(authorId: String) = authorId(JsonField.of(authorId)) - - /** The author id of the commit. */ - @JsonProperty("authorId") - @ExcludeMissing - fun authorId(authorId: JsonField) = apply { this.authorId = authorId } - - /** The commit creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = - dateCreated(JsonField.of(dateCreated)) - - /** The commit creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The size of the commit bundle in bytes. */ - fun fileSize(fileSize: Long) = fileSize(JsonField.of(fileSize)) - - /** The size of the commit bundle in bytes. */ - @JsonProperty("fileSize") - @ExcludeMissing - fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } - - /** The commit message. */ - fun message(message: String) = message(JsonField.of(message)) - - /** The commit message. */ - @JsonProperty("message") - @ExcludeMissing - fun message(message: JsonField) = apply { this.message = message } - - /** The model id. */ - fun mlModelId(mlModelId: String) = mlModelId(JsonField.of(mlModelId)) - - /** The model id. */ - @JsonProperty("mlModelId") - @ExcludeMissing - fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } - - /** The validation dataset id. */ - fun validationDatasetId(validationDatasetId: String) = - validationDatasetId(JsonField.of(validationDatasetId)) - - /** The validation dataset id. */ - @JsonProperty("validationDatasetId") - @ExcludeMissing - fun validationDatasetId(validationDatasetId: JsonField) = apply { - this.validationDatasetId = validationDatasetId - } - - /** The training dataset id. */ - fun trainingDatasetId(trainingDatasetId: String) = - trainingDatasetId(JsonField.of(trainingDatasetId)) - - /** The training dataset id. */ - @JsonProperty("trainingDatasetId") - @ExcludeMissing - fun trainingDatasetId(trainingDatasetId: JsonField) = apply { - this.trainingDatasetId = trainingDatasetId - } - - /** The storage URI where the commit bundle is stored. */ - fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) - - /** The storage URI where the commit bundle is stored. */ - @JsonProperty("storageUri") - @ExcludeMissing - fun storageUri(storageUri: JsonField) = apply { - this.storageUri = storageUri - } - - /** The SHA of the corresponding git commit. */ - fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) - - /** The SHA of the corresponding git commit. */ - @JsonProperty("gitCommitSha") - @ExcludeMissing - fun gitCommitSha(gitCommitSha: JsonField) = apply { - this.gitCommitSha = gitCommitSha - } - - /** The ref of the corresponding git commit. */ - fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) - - /** The ref of the corresponding git commit. */ - @JsonProperty("gitCommitRef") - @ExcludeMissing - fun gitCommitRef(gitCommitRef: JsonField) = apply { - this.gitCommitRef = gitCommitRef - } - - /** The URL of the corresponding git commit. */ - fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) - - /** The URL of the corresponding git commit. */ - @JsonProperty("gitCommitUrl") - @ExcludeMissing - fun gitCommitUrl(gitCommitUrl: JsonField) = apply { - this.gitCommitUrl = gitCommitUrl - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Commit = - Commit( - id, - authorId, - dateCreated, - fileSize, - message, - mlModelId, - validationDatasetId, - trainingDatasetId, - storageUri, - gitCommitSha, - gitCommitRef, - gitCommitUrl, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && dateCreated == other.dateCreated && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && validationDatasetId == other.validationDatasetId && trainingDatasetId == other.trainingDatasetId && storageUri == other.storageUri && gitCommitSha == other.gitCommitSha && gitCommitRef == other.gitCommitRef && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, authorId, dateCreated, fileSize, message, mlModelId, validationDatasetId, trainingDatasetId, storageUri, gitCommitSha, gitCommitRef, gitCommitUrl, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Commit{id=$id, authorId=$authorId, dateCreated=$dateCreated, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, storageUri=$storageUri, gitCommitSha=$gitCommitSha, gitCommitRef=$gitCommitRef, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && dateCreated == other.dateCreated && status == other.status && statusMessage == other.statusMessage && projectId == other.projectId && storageUri == other.storageUri && commit == other.commit && deploymentStatus == other.deploymentStatus && mlModelId == other.mlModelId && validationDatasetId == other.validationDatasetId && trainingDatasetId == other.trainingDatasetId && archived == other.archived && dateArchived == other.dateArchived && passingGoalCount == other.passingGoalCount && failingGoalCount == other.failingGoalCount && totalGoalCount == other.totalGoalCount && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, dateCreated, status, statusMessage, projectId, storageUri, commit, deploymentStatus, mlModelId, validationDatasetId, trainingDatasetId, archived, dateArchived, passingGoalCount, failingGoalCount, totalGoalCount, links, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, dateCreated=$dateCreated, status=$status, statusMessage=$statusMessage, projectId=$projectId, storageUri=$storageUri, commit=$commit, deploymentStatus=$deploymentStatus, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, archived=$archived, dateArchived=$dateArchived, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, links=$links, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCommitListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectCommitListResponse{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateParams.kt deleted file mode 100644 index d4130bdd..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateParams.kt +++ /dev/null @@ -1,708 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -class ProjectCreateParams -constructor( - private val name: String, - private val taskType: TaskType, - private val description: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun name(): String = name - - fun taskType(): TaskType = taskType - - fun description(): Optional = Optional.ofNullable(description) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectCreateBody { - return ProjectCreateBody( - name, - taskType, - description, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - - @JsonDeserialize(builder = ProjectCreateBody.Builder::class) - @NoAutoDetect - class ProjectCreateBody - internal constructor( - private val name: String?, - private val taskType: TaskType?, - private val description: String?, - private val additionalProperties: Map, - ) { - - /** The project name. */ - @JsonProperty("name") fun name(): String? = name - - /** The task type of the project. */ - @JsonProperty("taskType") fun taskType(): TaskType? = taskType - - /** The project description. */ - @JsonProperty("description") fun description(): String? = description - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var name: String? = null - private var taskType: TaskType? = null - private var description: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectCreateBody: ProjectCreateBody) = apply { - this.name = projectCreateBody.name - this.taskType = projectCreateBody.taskType - this.description = projectCreateBody.description - additionalProperties(projectCreateBody.additionalProperties) - } - - /** The project name. */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - /** The task type of the project. */ - @JsonProperty("taskType") - fun taskType(taskType: TaskType) = apply { this.taskType = taskType } - - /** The project description. */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectCreateBody = - ProjectCreateBody( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(taskType) { "`taskType` is required but was not set" }, - description, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCreateBody && name == other.name && taskType == other.taskType && description == other.description && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, taskType, description, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectCreateBody{name=$name, taskType=$taskType, description=$description, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var name: String? = null - private var taskType: TaskType? = null - private var description: 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(projectCreateParams: ProjectCreateParams) = apply { - name = projectCreateParams.name - taskType = projectCreateParams.taskType - description = projectCreateParams.description - additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = projectCreateParams.additionalBodyProperties.toMutableMap() - } - - /** The project name. */ - fun name(name: String) = apply { this.name = name } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = apply { this.taskType = taskType } - - /** The project description. */ - fun description(description: String) = apply { this.description = description } - - 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) - } - - fun build(): ProjectCreateParams = - ProjectCreateParams( - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(taskType) { "`taskType` is required but was not set" }, - description, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: String?, - private val additionalProperties: Map, - ) { - - @JsonProperty("app") fun app(): String? = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - @JsonProperty("app") fun app(app: String) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = - Links( - checkNotNull(app) { "`app` is required but was not set" }, - additionalProperties.toImmutable() - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: String?, - private val gitId: Long?, - private val dateConnected: OffsetDateTime?, - private val dateUpdated: OffsetDateTime?, - private val branch: String?, - private val name: String?, - private val private_: Boolean?, - private val slug: String?, - private val url: String?, - private val rootDir: String?, - private val projectId: String?, - private val gitAccountId: String?, - private val additionalProperties: Map, - ) { - - @JsonProperty("id") fun id(): String? = id - - @JsonProperty("gitId") fun gitId(): Long? = gitId - - @JsonProperty("dateConnected") fun dateConnected(): OffsetDateTime? = dateConnected - - @JsonProperty("dateUpdated") fun dateUpdated(): OffsetDateTime? = dateUpdated - - @JsonProperty("branch") fun branch(): String? = branch - - @JsonProperty("name") fun name(): String? = name - - @JsonProperty("private") fun private_(): Boolean? = private_ - - @JsonProperty("slug") fun slug(): String? = slug - - @JsonProperty("url") fun url(): String? = url - - @JsonProperty("rootDir") fun rootDir(): String? = rootDir - - @JsonProperty("projectId") fun projectId(): String? = projectId - - @JsonProperty("gitAccountId") fun gitAccountId(): String? = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var gitId: Long? = null - private var dateConnected: OffsetDateTime? = null - private var dateUpdated: OffsetDateTime? = null - private var branch: String? = null - private var name: String? = null - private var private_: Boolean? = null - private var slug: String? = null - private var url: String? = null - private var rootDir: String? = null - private var projectId: String? = null - private var gitAccountId: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - @JsonProperty("gitId") fun gitId(gitId: Long) = apply { this.gitId = gitId } - - @JsonProperty("dateConnected") - fun dateConnected(dateConnected: OffsetDateTime) = apply { - this.dateConnected = dateConnected - } - - @JsonProperty("dateUpdated") - fun dateUpdated(dateUpdated: OffsetDateTime) = apply { this.dateUpdated = dateUpdated } - - @JsonProperty("branch") fun branch(branch: String) = apply { this.branch = branch } - - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - @JsonProperty("private") - fun private_(private_: Boolean) = apply { this.private_ = private_ } - - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } - - @JsonProperty("url") fun url(url: String) = apply { this.url = url } - - @JsonProperty("rootDir") fun rootDir(rootDir: String) = apply { this.rootDir = rootDir } - - @JsonProperty("projectId") - fun projectId(projectId: String) = apply { this.projectId = projectId } - - @JsonProperty("gitAccountId") - fun gitAccountId(gitAccountId: String) = apply { this.gitAccountId = gitAccountId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - checkNotNull(id) { "`id` is required but was not set" }, - checkNotNull(gitId) { "`gitId` is required but was not set" }, - checkNotNull(dateConnected) { "`dateConnected` is required but was not set" }, - checkNotNull(dateUpdated) { "`dateUpdated` is required but was not set" }, - branch, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(private_) { "`private_` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - checkNotNull(url) { "`url` is required but was not set" }, - rootDir, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(gitAccountId) { "`gitAccountId` is required but was not set" }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCreateParams && name == other.name && taskType == other.taskType && description == other.description && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(name, taskType, description, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectCreateParams{name=$name, taskType=$taskType, description=$description, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateResponse.kt deleted file mode 100644 index 284779d0..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCreateResponse.kt +++ /dev/null @@ -1,889 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = ProjectCreateResponse.Builder::class) -@NoAutoDetect -class ProjectCreateResponse -private constructor( - private val id: JsonField, - private val workspaceId: JsonField, - private val creatorId: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonField, - private val source: JsonField, - private val taskType: JsonField, - private val versionCount: JsonField, - private val inferencePipelineCount: JsonField, - private val goalCount: JsonField, - private val developmentGoalCount: JsonField, - private val monitoringGoalCount: JsonField, - private val links: JsonField, - private val gitRepo: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The project id. */ - fun id(): String = id.getRequired("id") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - /** The project creator id. */ - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project name. */ - fun name(): String = name.getRequired("name") - - /** The project creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The project last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The project description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The source of the project. */ - fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - - /** The task type of the project. */ - fun taskType(): TaskType = taskType.getRequired("taskType") - - /** The number of versions (commits) in the project. */ - fun versionCount(): Long = versionCount.getRequired("versionCount") - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(): Long = - inferencePipelineCount.getRequired("inferencePipelineCount") - - /** The total number of tests in the project. */ - fun goalCount(): Long = goalCount.getRequired("goalCount") - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") - - /** Links to the project. */ - fun links(): Links = links.getRequired("links") - - fun gitRepo(): Optional = Optional.ofNullable(gitRepo.getNullable("gitRepo")) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The project creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The project description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The source of the project. */ - @JsonProperty("source") @ExcludeMissing fun _source() = source - - /** The task type of the project. */ - @JsonProperty("taskType") @ExcludeMissing fun _taskType() = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") @ExcludeMissing fun _versionCount() = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun _inferencePipelineCount() = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") @ExcludeMissing fun _goalCount() = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun _developmentGoalCount() = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun _monitoringGoalCount() = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo() = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectCreateResponse = apply { - if (!validated) { - id() - workspaceId() - creatorId() - name() - dateCreated() - dateUpdated() - description() - source() - taskType() - versionCount() - inferencePipelineCount() - goalCount() - developmentGoalCount() - monitoringGoalCount() - links().validate() - gitRepo().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var taskType: JsonField = JsonMissing.of() - private var versionCount: JsonField = JsonMissing.of() - private var inferencePipelineCount: JsonField = JsonMissing.of() - private var goalCount: JsonField = JsonMissing.of() - private var developmentGoalCount: JsonField = JsonMissing.of() - private var monitoringGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var gitRepo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectCreateResponse: ProjectCreateResponse) = apply { - this.id = projectCreateResponse.id - this.workspaceId = projectCreateResponse.workspaceId - this.creatorId = projectCreateResponse.creatorId - this.name = projectCreateResponse.name - this.dateCreated = projectCreateResponse.dateCreated - this.dateUpdated = projectCreateResponse.dateUpdated - this.description = projectCreateResponse.description - this.source = projectCreateResponse.source - this.taskType = projectCreateResponse.taskType - this.versionCount = projectCreateResponse.versionCount - this.inferencePipelineCount = projectCreateResponse.inferencePipelineCount - this.goalCount = projectCreateResponse.goalCount - this.developmentGoalCount = projectCreateResponse.developmentGoalCount - this.monitoringGoalCount = projectCreateResponse.monitoringGoalCount - this.links = projectCreateResponse.links - this.gitRepo = projectCreateResponse.gitRepo - additionalProperties(projectCreateResponse.additionalProperties) - } - - /** The project id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } - - /** The project creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The project creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The project name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The project creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The project last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The project description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The project description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The source of the project. */ - fun source(source: Source) = source(JsonField.of(source)) - - /** The source of the project. */ - @JsonProperty("source") - @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) - - /** The task type of the project. */ - @JsonProperty("taskType") - @ExcludeMissing - fun taskType(taskType: JsonField) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - @ExcludeMissing - fun versionCount(versionCount: JsonField) = apply { this.versionCount = versionCount } - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(inferencePipelineCount: Long) = - inferencePipelineCount(JsonField.of(inferencePipelineCount)) - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - @ExcludeMissing - fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(developmentGoalCount: Long) = - developmentGoalCount(JsonField.of(developmentGoalCount)) - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun developmentGoalCount(developmentGoalCount: JsonField) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(monitoringGoalCount: Long) = - monitoringGoalCount(JsonField.of(monitoringGoalCount)) - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - fun links(links: Links) = links(JsonField.of(links)) - - /** Links to the project. */ - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun gitRepo(gitRepo: GitRepo) = gitRepo(JsonField.of(gitRepo)) - - @JsonProperty("gitRepo") - @ExcludeMissing - fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectCreateResponse = - ProjectCreateResponse( - id, - workspaceId, - creatorId, - name, - dateCreated, - dateUpdated, - description, - source, - taskType, - versionCount, - inferencePipelineCount, - goalCount, - developmentGoalCount, - monitoringGoalCount, - links, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: JsonField, - private val gitId: JsonField, - private val dateConnected: JsonField, - private val dateUpdated: JsonField, - private val branch: JsonField, - private val name: JsonField, - private val private_: JsonField, - private val slug: JsonField, - private val url: JsonField, - private val rootDir: JsonField, - private val projectId: JsonField, - private val gitAccountId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun gitId(): Long = gitId.getRequired("gitId") - - fun dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - - fun name(): String = name.getRequired("name") - - fun private_(): Boolean = private_.getRequired("private") - - fun slug(): String = slug.getRequired("slug") - - fun url(): String = url.getRequired("url") - - fun rootDir(): Optional = Optional.ofNullable(rootDir.getNullable("rootDir")) - - fun projectId(): String = projectId.getRequired("projectId") - - fun gitAccountId(): String = gitAccountId.getRequired("gitAccountId") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("gitId") @ExcludeMissing fun _gitId() = gitId - - @JsonProperty("dateConnected") @ExcludeMissing fun _dateConnected() = dateConnected - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("private") @ExcludeMissing fun _private_() = private_ - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("rootDir") @ExcludeMissing fun _rootDir() = rootDir - - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("gitAccountId") @ExcludeMissing fun _gitAccountId() = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitRepo = apply { - if (!validated) { - id() - gitId() - dateConnected() - dateUpdated() - branch() - name() - private_() - slug() - url() - rootDir() - projectId() - gitAccountId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var gitId: JsonField = JsonMissing.of() - private var dateConnected: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var private_: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var rootDir: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var gitAccountId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) - - @JsonProperty("gitId") - @ExcludeMissing - fun gitId(gitId: JsonField) = apply { this.gitId = gitId } - - fun dateConnected(dateConnected: OffsetDateTime) = - dateConnected(JsonField.of(dateConnected)) - - @JsonProperty("dateConnected") - @ExcludeMissing - fun dateConnected(dateConnected: JsonField) = apply { - this.dateConnected = dateConnected - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun branch(branch: String) = branch(JsonField.of(branch)) - - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun private_(private_: Boolean) = private_(JsonField.of(private_)) - - @JsonProperty("private") - @ExcludeMissing - fun private_(private_: JsonField) = apply { this.private_ = private_ } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) - - @JsonProperty("rootDir") - @ExcludeMissing - fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) - - @JsonProperty("gitAccountId") - @ExcludeMissing - fun gitAccountId(gitAccountId: JsonField) = apply { - this.gitAccountId = gitAccountId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - id, - gitId, - dateConnected, - dateUpdated, - branch, - name, - private_, - slug, - url, - rootDir, - projectId, - gitAccountId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectCreateResponse && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectCreateResponse{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateParams.kt deleted file mode 100644 index 39cf115e..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateParams.kt +++ /dev/null @@ -1,1559 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.http.Headers -import com.openlayer.api.core.http.QueryParams -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -class ProjectInferencePipelineCreateParams -constructor( - private val projectId: String, - private val description: String?, - private val name: String, - private val project: Project?, - private val workspace: Workspace?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) { - - fun projectId(): String = projectId - - fun description(): Optional = Optional.ofNullable(description) - - fun name(): String = name - - fun project(): Optional = Optional.ofNullable(project) - - fun workspace(): Optional = Optional.ofNullable(workspace) - - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun _additionalBodyProperties(): Map = additionalBodyProperties - - @JvmSynthetic - internal fun getBody(): ProjectInferencePipelineCreateBody { - return ProjectInferencePipelineCreateBody( - description, - name, - project, - workspace, - additionalBodyProperties, - ) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } - } - - @JsonDeserialize(builder = ProjectInferencePipelineCreateBody.Builder::class) - @NoAutoDetect - class ProjectInferencePipelineCreateBody - internal constructor( - private val description: String?, - private val name: String?, - private val project: Project?, - private val workspace: Workspace?, - private val additionalProperties: Map, - ) { - - /** The inference pipeline description. */ - @JsonProperty("description") fun description(): String? = description - - /** The inference pipeline name. */ - @JsonProperty("name") fun name(): String? = name - - @JsonProperty("project") fun project(): Project? = project - - @JsonProperty("workspace") fun workspace(): Workspace? = workspace - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var description: String? = null - private var name: String? = null - private var project: Project? = null - private var workspace: Workspace? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - projectInferencePipelineCreateBody: ProjectInferencePipelineCreateBody - ) = apply { - this.description = projectInferencePipelineCreateBody.description - this.name = projectInferencePipelineCreateBody.name - this.project = projectInferencePipelineCreateBody.project - this.workspace = projectInferencePipelineCreateBody.workspace - additionalProperties(projectInferencePipelineCreateBody.additionalProperties) - } - - /** The inference pipeline description. */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } - - /** The inference pipeline name. */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - @JsonProperty("project") - fun project(project: Project) = apply { this.project = project } - - @JsonProperty("workspace") - fun workspace(workspace: Workspace) = apply { this.workspace = workspace } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectInferencePipelineCreateBody = - ProjectInferencePipelineCreateBody( - description, - checkNotNull(name) { "`name` is required but was not set" }, - project, - workspace, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectInferencePipelineCreateBody && description == other.description && name == other.name && project == other.project && workspace == other.workspace && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(description, name, project, workspace, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectInferencePipelineCreateBody{description=$description, name=$name, project=$project, workspace=$workspace, additionalProperties=$additionalProperties}" - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - - private var projectId: String? = null - private var description: String? = null - private var name: String? = null - private var project: Project? = null - private var workspace: Workspace? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - projectInferencePipelineCreateParams: ProjectInferencePipelineCreateParams - ) = apply { - projectId = projectInferencePipelineCreateParams.projectId - description = projectInferencePipelineCreateParams.description - name = projectInferencePipelineCreateParams.name - project = projectInferencePipelineCreateParams.project - workspace = projectInferencePipelineCreateParams.workspace - additionalHeaders = projectInferencePipelineCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = - projectInferencePipelineCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - projectInferencePipelineCreateParams.additionalBodyProperties.toMutableMap() - } - - fun projectId(projectId: String) = apply { this.projectId = projectId } - - /** The inference pipeline description. */ - fun description(description: String) = apply { this.description = description } - - /** The inference pipeline name. */ - fun name(name: String) = apply { this.name = name } - - fun project(project: Project) = apply { this.project = project } - - fun workspace(workspace: Workspace) = apply { this.workspace = workspace } - - 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) - } - - fun build(): ProjectInferencePipelineCreateParams = - ProjectInferencePipelineCreateParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - description, - checkNotNull(name) { "`name` is required but was not set" }, - project, - workspace, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: String?, - private val additionalProperties: Map, - ) { - - @JsonProperty("app") fun app(): String? = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - @JsonProperty("app") fun app(app: String) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = - Links( - checkNotNull(app) { "`app` is required but was not set" }, - additionalProperties.toImmutable() - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Project.Builder::class) - @NoAutoDetect - class Project - private constructor( - private val id: String?, - private val workspaceId: String?, - private val creatorId: String?, - private val name: String?, - private val dateCreated: OffsetDateTime?, - private val dateUpdated: OffsetDateTime?, - private val description: String?, - private val source: Source?, - private val taskType: TaskType?, - private val versionCount: Long?, - private val inferencePipelineCount: Long?, - private val goalCount: Long?, - private val developmentGoalCount: Long?, - private val monitoringGoalCount: Long?, - private val links: Links?, - private val gitRepo: GitRepo?, - private val additionalProperties: Map, - ) { - - /** The project id. */ - @JsonProperty("id") fun id(): String? = id - - /** The workspace id. */ - @JsonProperty("workspaceId") fun workspaceId(): String? = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") fun creatorId(): String? = creatorId - - /** The project name. */ - @JsonProperty("name") fun name(): String? = name - - /** The project creation date. */ - @JsonProperty("dateCreated") fun dateCreated(): OffsetDateTime? = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") fun dateUpdated(): OffsetDateTime? = dateUpdated - - /** The project description. */ - @JsonProperty("description") fun description(): String? = description - - /** The source of the project. */ - @JsonProperty("source") fun source(): Source? = source - - /** The task type of the project. */ - @JsonProperty("taskType") fun taskType(): TaskType? = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") fun versionCount(): Long? = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - fun inferencePipelineCount(): Long? = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") fun goalCount(): Long? = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - fun developmentGoalCount(): Long? = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") fun monitoringGoalCount(): Long? = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") fun links(): Links? = links - - @JsonProperty("gitRepo") fun gitRepo(): GitRepo? = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var workspaceId: String? = null - private var creatorId: String? = null - private var name: String? = null - private var dateCreated: OffsetDateTime? = null - private var dateUpdated: OffsetDateTime? = null - private var description: String? = null - private var source: Source? = null - private var taskType: TaskType? = null - private var versionCount: Long? = null - private var inferencePipelineCount: Long? = null - private var goalCount: Long? = null - private var developmentGoalCount: Long? = null - private var monitoringGoalCount: Long? = null - private var links: Links? = null - private var gitRepo: GitRepo? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(project: Project) = apply { - this.id = project.id - this.workspaceId = project.workspaceId - this.creatorId = project.creatorId - this.name = project.name - this.dateCreated = project.dateCreated - this.dateUpdated = project.dateUpdated - this.description = project.description - this.source = project.source - this.taskType = project.taskType - this.versionCount = project.versionCount - this.inferencePipelineCount = project.inferencePipelineCount - this.goalCount = project.goalCount - this.developmentGoalCount = project.developmentGoalCount - this.monitoringGoalCount = project.monitoringGoalCount - this.links = project.links - this.gitRepo = project.gitRepo - additionalProperties(project.additionalProperties) - } - - /** The project id. */ - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - /** The workspace id. */ - @JsonProperty("workspaceId") - fun workspaceId(workspaceId: String) = apply { this.workspaceId = workspaceId } - - /** The project creator id. */ - @JsonProperty("creatorId") - fun creatorId(creatorId: String) = apply { this.creatorId = creatorId } - - /** The project name. */ - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - /** The project creation date. */ - @JsonProperty("dateCreated") - fun dateCreated(dateCreated: OffsetDateTime) = apply { this.dateCreated = dateCreated } - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - fun dateUpdated(dateUpdated: OffsetDateTime) = apply { this.dateUpdated = dateUpdated } - - /** The project description. */ - @JsonProperty("description") - fun description(description: String) = apply { this.description = description } - - /** The source of the project. */ - @JsonProperty("source") fun source(source: Source) = apply { this.source = source } - - /** The task type of the project. */ - @JsonProperty("taskType") - fun taskType(taskType: TaskType) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - fun versionCount(versionCount: Long) = apply { this.versionCount = versionCount } - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - fun inferencePipelineCount(inferencePipelineCount: Long) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - fun goalCount(goalCount: Long) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - fun developmentGoalCount(developmentGoalCount: Long) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - fun monitoringGoalCount(monitoringGoalCount: Long) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - @JsonProperty("links") fun links(links: Links) = apply { this.links = links } - - @JsonProperty("gitRepo") - fun gitRepo(gitRepo: GitRepo) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Project = - Project( - checkNotNull(id) { "`id` is required but was not set" }, - workspaceId, - creatorId, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(dateCreated) { "`dateCreated` is required but was not set" }, - checkNotNull(dateUpdated) { "`dateUpdated` is required but was not set" }, - description, - source, - checkNotNull(taskType) { "`taskType` is required but was not set" }, - checkNotNull(versionCount) { "`versionCount` is required but was not set" }, - checkNotNull(inferencePipelineCount) { - "`inferencePipelineCount` is required but was not set" - }, - checkNotNull(goalCount) { "`goalCount` is required but was not set" }, - checkNotNull(developmentGoalCount) { - "`developmentGoalCount` is required but was not set" - }, - checkNotNull(monitoringGoalCount) { - "`monitoringGoalCount` is required but was not set" - }, - checkNotNull(links) { "`links` is required but was not set" }, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: String?, - private val additionalProperties: Map, - ) { - - @JsonProperty("app") fun app(): String? = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - @JsonProperty("app") fun app(app: String) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = - Links( - checkNotNull(app) { "`app` is required but was not set" }, - additionalProperties.toImmutable() - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: String?, - private val gitId: Long?, - private val dateConnected: OffsetDateTime?, - private val dateUpdated: OffsetDateTime?, - private val branch: String?, - private val name: String?, - private val private_: Boolean?, - private val slug: String?, - private val url: String?, - private val rootDir: String?, - private val projectId: String?, - private val gitAccountId: String?, - private val additionalProperties: Map, - ) { - - @JsonProperty("id") fun id(): String? = id - - @JsonProperty("gitId") fun gitId(): Long? = gitId - - @JsonProperty("dateConnected") fun dateConnected(): OffsetDateTime? = dateConnected - - @JsonProperty("dateUpdated") fun dateUpdated(): OffsetDateTime? = dateUpdated - - @JsonProperty("branch") fun branch(): String? = branch - - @JsonProperty("name") fun name(): String? = name - - @JsonProperty("private") fun private_(): Boolean? = private_ - - @JsonProperty("slug") fun slug(): String? = slug - - @JsonProperty("url") fun url(): String? = url - - @JsonProperty("rootDir") fun rootDir(): String? = rootDir - - @JsonProperty("projectId") fun projectId(): String? = projectId - - @JsonProperty("gitAccountId") fun gitAccountId(): String? = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var gitId: Long? = null - private var dateConnected: OffsetDateTime? = null - private var dateUpdated: OffsetDateTime? = null - private var branch: String? = null - private var name: String? = null - private var private_: Boolean? = null - private var slug: String? = null - private var url: String? = null - private var rootDir: String? = null - private var projectId: String? = null - private var gitAccountId: String? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - @JsonProperty("gitId") fun gitId(gitId: Long) = apply { this.gitId = gitId } - - @JsonProperty("dateConnected") - fun dateConnected(dateConnected: OffsetDateTime) = apply { - this.dateConnected = dateConnected - } - - @JsonProperty("dateUpdated") - fun dateUpdated(dateUpdated: OffsetDateTime) = apply { - this.dateUpdated = dateUpdated - } - - @JsonProperty("branch") fun branch(branch: String) = apply { this.branch = branch } - - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - @JsonProperty("private") - fun private_(private_: Boolean) = apply { this.private_ = private_ } - - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } - - @JsonProperty("url") fun url(url: String) = apply { this.url = url } - - @JsonProperty("rootDir") - fun rootDir(rootDir: String) = apply { this.rootDir = rootDir } - - @JsonProperty("projectId") - fun projectId(projectId: String) = apply { this.projectId = projectId } - - @JsonProperty("gitAccountId") - fun gitAccountId(gitAccountId: String) = apply { this.gitAccountId = gitAccountId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - checkNotNull(id) { "`id` is required but was not set" }, - checkNotNull(gitId) { "`gitId` is required but was not set" }, - checkNotNull(dateConnected) { - "`dateConnected` is required but was not set" - }, - checkNotNull(dateUpdated) { "`dateUpdated` is required but was not set" }, - branch, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(private_) { "`private_` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - checkNotNull(url) { "`url` is required but was not set" }, - rootDir, - checkNotNull(projectId) { "`projectId` is required but was not set" }, - checkNotNull(gitAccountId) { "`gitAccountId` is required but was not set" }, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Project && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Project{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Workspace.Builder::class) - @NoAutoDetect - class Workspace - private constructor( - private val id: String?, - private val name: String?, - private val slug: String?, - private val dateCreated: OffsetDateTime?, - private val dateUpdated: OffsetDateTime?, - private val creatorId: String?, - private val inviteCode: String?, - private val wildcardDomains: List?, - private val projectCount: Long?, - private val memberCount: Long?, - private val monthlyUsage: List?, - private val inviteCount: Long?, - private val periodStartDate: OffsetDateTime?, - private val periodEndDate: OffsetDateTime?, - private val samlOnlyAccess: Boolean?, - private val status: Status?, - private val additionalProperties: Map, - ) { - - @JsonProperty("id") fun id(): String? = id - - @JsonProperty("name") fun name(): String? = name - - @JsonProperty("slug") fun slug(): String? = slug - - @JsonProperty("dateCreated") fun dateCreated(): OffsetDateTime? = dateCreated - - @JsonProperty("dateUpdated") fun dateUpdated(): OffsetDateTime? = dateUpdated - - @JsonProperty("creatorId") fun creatorId(): String? = creatorId - - @JsonProperty("inviteCode") fun inviteCode(): String? = inviteCode - - @JsonProperty("wildcardDomains") fun wildcardDomains(): List? = wildcardDomains - - @JsonProperty("projectCount") fun projectCount(): Long? = projectCount - - @JsonProperty("memberCount") fun memberCount(): Long? = memberCount - - @JsonProperty("monthlyUsage") fun monthlyUsage(): List? = monthlyUsage - - @JsonProperty("inviteCount") fun inviteCount(): Long? = inviteCount - - @JsonProperty("periodStartDate") fun periodStartDate(): OffsetDateTime? = periodStartDate - - @JsonProperty("periodEndDate") fun periodEndDate(): OffsetDateTime? = periodEndDate - - @JsonProperty("samlOnlyAccess") fun samlOnlyAccess(): Boolean? = samlOnlyAccess - - @JsonProperty("status") fun status(): Status? = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: String? = null - private var name: String? = null - private var slug: String? = null - private var dateCreated: OffsetDateTime? = null - private var dateUpdated: OffsetDateTime? = null - private var creatorId: String? = null - private var inviteCode: String? = null - private var wildcardDomains: List? = null - private var projectCount: Long? = null - private var memberCount: Long? = null - private var monthlyUsage: List? = null - private var inviteCount: Long? = null - private var periodStartDate: OffsetDateTime? = null - private var periodEndDate: OffsetDateTime? = null - private var samlOnlyAccess: Boolean? = null - private var status: Status? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(workspace: Workspace) = apply { - this.id = workspace.id - this.name = workspace.name - this.slug = workspace.slug - this.dateCreated = workspace.dateCreated - this.dateUpdated = workspace.dateUpdated - this.creatorId = workspace.creatorId - this.inviteCode = workspace.inviteCode - this.wildcardDomains = workspace.wildcardDomains - this.projectCount = workspace.projectCount - this.memberCount = workspace.memberCount - this.monthlyUsage = workspace.monthlyUsage - this.inviteCount = workspace.inviteCount - this.periodStartDate = workspace.periodStartDate - this.periodEndDate = workspace.periodEndDate - this.samlOnlyAccess = workspace.samlOnlyAccess - this.status = workspace.status - additionalProperties(workspace.additionalProperties) - } - - @JsonProperty("id") fun id(id: String) = apply { this.id = id } - - @JsonProperty("name") fun name(name: String) = apply { this.name = name } - - @JsonProperty("slug") fun slug(slug: String) = apply { this.slug = slug } - - @JsonProperty("dateCreated") - fun dateCreated(dateCreated: OffsetDateTime) = apply { this.dateCreated = dateCreated } - - @JsonProperty("dateUpdated") - fun dateUpdated(dateUpdated: OffsetDateTime) = apply { this.dateUpdated = dateUpdated } - - @JsonProperty("creatorId") - fun creatorId(creatorId: String) = apply { this.creatorId = creatorId } - - @JsonProperty("inviteCode") - fun inviteCode(inviteCode: String) = apply { this.inviteCode = inviteCode } - - @JsonProperty("wildcardDomains") - fun wildcardDomains(wildcardDomains: List) = apply { - this.wildcardDomains = wildcardDomains - } - - @JsonProperty("projectCount") - fun projectCount(projectCount: Long) = apply { this.projectCount = projectCount } - - @JsonProperty("memberCount") - fun memberCount(memberCount: Long) = apply { this.memberCount = memberCount } - - @JsonProperty("monthlyUsage") - fun monthlyUsage(monthlyUsage: List) = apply { - this.monthlyUsage = monthlyUsage - } - - @JsonProperty("inviteCount") - fun inviteCount(inviteCount: Long) = apply { this.inviteCount = inviteCount } - - @JsonProperty("periodStartDate") - fun periodStartDate(periodStartDate: OffsetDateTime) = apply { - this.periodStartDate = periodStartDate - } - - @JsonProperty("periodEndDate") - fun periodEndDate(periodEndDate: OffsetDateTime) = apply { - this.periodEndDate = periodEndDate - } - - @JsonProperty("samlOnlyAccess") - fun samlOnlyAccess(samlOnlyAccess: Boolean) = apply { - this.samlOnlyAccess = samlOnlyAccess - } - - @JsonProperty("status") fun status(status: Status) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Workspace = - Workspace( - checkNotNull(id) { "`id` is required but was not set" }, - checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(slug) { "`slug` is required but was not set" }, - checkNotNull(dateCreated) { "`dateCreated` is required but was not set" }, - checkNotNull(dateUpdated) { "`dateUpdated` is required but was not set" }, - creatorId, - inviteCode, - wildcardDomains?.toImmutable(), - checkNotNull(projectCount) { "`projectCount` is required but was not set" }, - checkNotNull(memberCount) { "`memberCount` is required but was not set" }, - monthlyUsage?.toImmutable(), - checkNotNull(inviteCount) { "`inviteCount` is required but was not set" }, - periodStartDate, - periodEndDate, - samlOnlyAccess, - checkNotNull(status) { "`status` is required but was not set" }, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val PAST_DUE = of("past_due") - - @JvmField val UNPAID = of("unpaid") - - @JvmField val CANCELED = of("canceled") - - @JvmField val INCOMPLETE = of("incomplete") - - @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") - - @JvmField val TRIALING = of("trialing") - - @JvmField val PAUSED = of("paused") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - } - - enum class Value { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - PAST_DUE -> Value.PAST_DUE - UNPAID -> Value.UNPAID - CANCELED -> Value.CANCELED - INCOMPLETE -> Value.INCOMPLETE - INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED - TRIALING -> Value.TRIALING - PAUSED -> Value.PAUSED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - PAST_DUE -> Known.PAST_DUE - UNPAID -> Known.UNPAID - CANCELED -> Known.CANCELED - INCOMPLETE -> Known.INCOMPLETE - INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED - TRIALING -> Known.TRIALING - PAUSED -> Known.PAUSED - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = MonthlyUsage.Builder::class) - @NoAutoDetect - class MonthlyUsage - private constructor( - private val monthYear: LocalDate?, - private val predictionCount: Long?, - private val executionTimeMs: Long?, - private val additionalProperties: Map, - ) { - - @JsonProperty("monthYear") fun monthYear(): LocalDate? = monthYear - - @JsonProperty("predictionCount") fun predictionCount(): Long? = predictionCount - - @JsonProperty("executionTimeMs") fun executionTimeMs(): Long? = executionTimeMs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var monthYear: LocalDate? = null - private var predictionCount: Long? = null - private var executionTimeMs: Long? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monthlyUsage: MonthlyUsage) = apply { - this.monthYear = monthlyUsage.monthYear - this.predictionCount = monthlyUsage.predictionCount - this.executionTimeMs = monthlyUsage.executionTimeMs - additionalProperties(monthlyUsage.additionalProperties) - } - - @JsonProperty("monthYear") - fun monthYear(monthYear: LocalDate) = apply { this.monthYear = monthYear } - - @JsonProperty("predictionCount") - fun predictionCount(predictionCount: Long) = apply { - this.predictionCount = predictionCount - } - - @JsonProperty("executionTimeMs") - fun executionTimeMs(executionTimeMs: Long) = apply { - this.executionTimeMs = executionTimeMs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MonthlyUsage = - MonthlyUsage( - monthYear, - predictionCount, - executionTimeMs, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonthlyUsage && monthYear == other.monthYear && predictionCount == other.predictionCount && executionTimeMs == other.executionTimeMs && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(monthYear, predictionCount, executionTimeMs, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonthlyUsage{monthYear=$monthYear, predictionCount=$predictionCount, executionTimeMs=$executionTimeMs, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Workspace && id == other.id && name == other.name && slug == other.slug && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && creatorId == other.creatorId && inviteCode == other.inviteCode && wildcardDomains == other.wildcardDomains && projectCount == other.projectCount && memberCount == other.memberCount && monthlyUsage == other.monthlyUsage && inviteCount == other.inviteCount && periodStartDate == other.periodStartDate && periodEndDate == other.periodEndDate && samlOnlyAccess == other.samlOnlyAccess && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, slug, dateCreated, dateUpdated, creatorId, inviteCode, wildcardDomains, projectCount, memberCount, monthlyUsage, inviteCount, periodStartDate, periodEndDate, samlOnlyAccess, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Workspace{id=$id, name=$name, slug=$slug, dateCreated=$dateCreated, dateUpdated=$dateUpdated, creatorId=$creatorId, inviteCode=$inviteCode, wildcardDomains=$wildcardDomains, projectCount=$projectCount, memberCount=$memberCount, monthlyUsage=$monthlyUsage, inviteCount=$inviteCount, periodStartDate=$periodStartDate, periodEndDate=$periodEndDate, samlOnlyAccess=$samlOnlyAccess, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectInferencePipelineCreateParams && projectId == other.projectId && description == other.description && name == other.name && project == other.project && workspace == other.workspace && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, description, name, project, workspace, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ - - override fun toString() = - "ProjectInferencePipelineCreateParams{projectId=$projectId, description=$description, name=$name, project=$project, workspace=$workspace, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateResponse.kt deleted file mode 100644 index 44828f13..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateResponse.kt +++ /dev/null @@ -1,2069 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = ProjectInferencePipelineCreateResponse.Builder::class) -@NoAutoDetect -class ProjectInferencePipelineCreateResponse -private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val workspaceId: JsonField, - private val project: JsonField, - private val workspace: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val dateLastSampleReceived: JsonField, - private val description: JsonField, - private val dateLastEvaluated: JsonField, - private val dateOfNextEvaluation: JsonField, - private val passingGoalCount: JsonField, - private val failingGoalCount: JsonField, - private val totalGoalCount: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val links: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The inference pipeline id. */ - fun id(): String = id.getRequired("id") - - /** The project id. */ - fun projectId(): String = projectId.getRequired("projectId") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - fun project(): Optional = Optional.ofNullable(project.getNullable("project")) - - fun workspace(): Optional = Optional.ofNullable(workspace.getNullable("workspace")) - - /** The inference pipeline name. */ - fun name(): String = name.getRequired("name") - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The last data sample received date. */ - fun dateLastSampleReceived(): Optional = - Optional.ofNullable(dateLastSampleReceived.getNullable("dateLastSampleReceived")) - - /** The inference pipeline description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The last test evaluation date. */ - fun dateLastEvaluated(): Optional = - Optional.ofNullable(dateLastEvaluated.getNullable("dateLastEvaluated")) - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(): Optional = - Optional.ofNullable(dateOfNextEvaluation.getNullable("dateOfNextEvaluation")) - - /** The number of tests passing. */ - fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") - - /** The number of tests failing. */ - fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") - - /** The total number of tests. */ - fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") - - /** The status of test evaluation for the inference pipeline. */ - fun status(): Status = status.getRequired("status") - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - fun links(): Links = links.getRequired("links") - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The project id. */ - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - @JsonProperty("project") @ExcludeMissing fun _project() = project - - @JsonProperty("workspace") @ExcludeMissing fun _workspace() = workspace - - /** The inference pipeline name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun _dateLastSampleReceived() = dateLastSampleReceived - - /** The inference pipeline description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") @ExcludeMissing fun _dateLastEvaluated() = dateLastEvaluated - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun _dateOfNextEvaluation() = dateOfNextEvaluation - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectInferencePipelineCreateResponse = apply { - if (!validated) { - id() - projectId() - workspaceId() - project().map { it.validate() } - workspace().map { it.validate() } - name() - dateCreated() - dateUpdated() - dateLastSampleReceived() - description() - dateLastEvaluated() - dateOfNextEvaluation() - passingGoalCount() - failingGoalCount() - totalGoalCount() - status() - statusMessage() - links().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var project: JsonField = JsonMissing.of() - private var workspace: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var dateLastSampleReceived: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dateLastEvaluated: JsonField = JsonMissing.of() - private var dateOfNextEvaluation: JsonField = JsonMissing.of() - private var passingGoalCount: JsonField = JsonMissing.of() - private var failingGoalCount: JsonField = JsonMissing.of() - private var totalGoalCount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - projectInferencePipelineCreateResponse: ProjectInferencePipelineCreateResponse - ) = apply { - this.id = projectInferencePipelineCreateResponse.id - this.projectId = projectInferencePipelineCreateResponse.projectId - this.workspaceId = projectInferencePipelineCreateResponse.workspaceId - this.project = projectInferencePipelineCreateResponse.project - this.workspace = projectInferencePipelineCreateResponse.workspace - this.name = projectInferencePipelineCreateResponse.name - this.dateCreated = projectInferencePipelineCreateResponse.dateCreated - this.dateUpdated = projectInferencePipelineCreateResponse.dateUpdated - this.dateLastSampleReceived = - projectInferencePipelineCreateResponse.dateLastSampleReceived - this.description = projectInferencePipelineCreateResponse.description - this.dateLastEvaluated = projectInferencePipelineCreateResponse.dateLastEvaluated - this.dateOfNextEvaluation = projectInferencePipelineCreateResponse.dateOfNextEvaluation - this.passingGoalCount = projectInferencePipelineCreateResponse.passingGoalCount - this.failingGoalCount = projectInferencePipelineCreateResponse.failingGoalCount - this.totalGoalCount = projectInferencePipelineCreateResponse.totalGoalCount - this.status = projectInferencePipelineCreateResponse.status - this.statusMessage = projectInferencePipelineCreateResponse.statusMessage - this.links = projectInferencePipelineCreateResponse.links - additionalProperties(projectInferencePipelineCreateResponse.additionalProperties) - } - - /** The inference pipeline id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } - - /** The project id. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** The project id. */ - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } - - fun project(project: Project) = project(JsonField.of(project)) - - @JsonProperty("project") - @ExcludeMissing - fun project(project: JsonField) = apply { this.project = project } - - fun workspace(workspace: Workspace) = workspace(JsonField.of(workspace)) - - @JsonProperty("workspace") - @ExcludeMissing - fun workspace(workspace: JsonField) = apply { this.workspace = workspace } - - /** The inference pipeline name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The inference pipeline name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The last data sample received date. */ - fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime) = - dateLastSampleReceived(JsonField.of(dateLastSampleReceived)) - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { - this.dateLastSampleReceived = dateLastSampleReceived - } - - /** The inference pipeline description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The inference pipeline description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { this.description = description } - - /** The last test evaluation date. */ - fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime) = - dateLastEvaluated(JsonField.of(dateLastEvaluated)) - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") - @ExcludeMissing - fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { - this.dateLastEvaluated = dateLastEvaluated - } - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime) = - dateOfNextEvaluation(JsonField.of(dateOfNextEvaluation)) - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { - this.dateOfNextEvaluation = dateOfNextEvaluation - } - - /** The number of tests passing. */ - fun passingGoalCount(passingGoalCount: Long) = - passingGoalCount(JsonField.of(passingGoalCount)) - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") - @ExcludeMissing - fun passingGoalCount(passingGoalCount: JsonField) = apply { - this.passingGoalCount = passingGoalCount - } - - /** The number of tests failing. */ - fun failingGoalCount(failingGoalCount: Long) = - failingGoalCount(JsonField.of(failingGoalCount)) - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") - @ExcludeMissing - fun failingGoalCount(failingGoalCount: JsonField) = apply { - this.failingGoalCount = failingGoalCount - } - - /** The total number of tests. */ - fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") - @ExcludeMissing - fun totalGoalCount(totalGoalCount: JsonField) = apply { - this.totalGoalCount = totalGoalCount - } - - /** The status of test evaluation for the inference pipeline. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - fun links(links: Links) = links(JsonField.of(links)) - - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectInferencePipelineCreateResponse = - ProjectInferencePipelineCreateResponse( - id, - projectId, - workspaceId, - project, - workspace, - name, - dateCreated, - dateUpdated, - dateLastSampleReceived, - description, - dateLastEvaluated, - dateOfNextEvaluation, - passingGoalCount, - failingGoalCount, - totalGoalCount, - status, - statusMessage, - links, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Project.Builder::class) - @NoAutoDetect - class Project - private constructor( - private val id: JsonField, - private val workspaceId: JsonField, - private val creatorId: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonField, - private val source: JsonField, - private val taskType: JsonField, - private val versionCount: JsonField, - private val inferencePipelineCount: JsonField, - private val goalCount: JsonField, - private val developmentGoalCount: JsonField, - private val monitoringGoalCount: JsonField, - private val links: JsonField, - private val gitRepo: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The project id. */ - fun id(): String = id.getRequired("id") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - /** The project creator id. */ - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project name. */ - fun name(): String = name.getRequired("name") - - /** The project creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The project last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The project description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The source of the project. */ - fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - - /** The task type of the project. */ - fun taskType(): TaskType = taskType.getRequired("taskType") - - /** The number of versions (commits) in the project. */ - fun versionCount(): Long = versionCount.getRequired("versionCount") - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(): Long = - inferencePipelineCount.getRequired("inferencePipelineCount") - - /** The total number of tests in the project. */ - fun goalCount(): Long = goalCount.getRequired("goalCount") - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") - - /** Links to the project. */ - fun links(): Links = links.getRequired("links") - - fun gitRepo(): Optional = Optional.ofNullable(gitRepo.getNullable("gitRepo")) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The project creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The project description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The source of the project. */ - @JsonProperty("source") @ExcludeMissing fun _source() = source - - /** The task type of the project. */ - @JsonProperty("taskType") @ExcludeMissing fun _taskType() = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") @ExcludeMissing fun _versionCount() = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun _inferencePipelineCount() = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") @ExcludeMissing fun _goalCount() = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun _developmentGoalCount() = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun _monitoringGoalCount() = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo() = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Project = apply { - if (!validated) { - id() - workspaceId() - creatorId() - name() - dateCreated() - dateUpdated() - description() - source() - taskType() - versionCount() - inferencePipelineCount() - goalCount() - developmentGoalCount() - monitoringGoalCount() - links().validate() - gitRepo().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var taskType: JsonField = JsonMissing.of() - private var versionCount: JsonField = JsonMissing.of() - private var inferencePipelineCount: JsonField = JsonMissing.of() - private var goalCount: JsonField = JsonMissing.of() - private var developmentGoalCount: JsonField = JsonMissing.of() - private var monitoringGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var gitRepo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(project: Project) = apply { - this.id = project.id - this.workspaceId = project.workspaceId - this.creatorId = project.creatorId - this.name = project.name - this.dateCreated = project.dateCreated - this.dateUpdated = project.dateUpdated - this.description = project.description - this.source = project.source - this.taskType = project.taskType - this.versionCount = project.versionCount - this.inferencePipelineCount = project.inferencePipelineCount - this.goalCount = project.goalCount - this.developmentGoalCount = project.developmentGoalCount - this.monitoringGoalCount = project.monitoringGoalCount - this.links = project.links - this.gitRepo = project.gitRepo - additionalProperties(project.additionalProperties) - } - - /** The project id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { - this.workspaceId = workspaceId - } - - /** The project creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The project creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The project name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The project creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The project last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The project description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The project description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - /** The source of the project. */ - fun source(source: Source) = source(JsonField.of(source)) - - /** The source of the project. */ - @JsonProperty("source") - @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) - - /** The task type of the project. */ - @JsonProperty("taskType") - @ExcludeMissing - fun taskType(taskType: JsonField) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - @ExcludeMissing - fun versionCount(versionCount: JsonField) = apply { - this.versionCount = versionCount - } - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(inferencePipelineCount: Long) = - inferencePipelineCount(JsonField.of(inferencePipelineCount)) - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - @ExcludeMissing - fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(developmentGoalCount: Long) = - developmentGoalCount(JsonField.of(developmentGoalCount)) - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun developmentGoalCount(developmentGoalCount: JsonField) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(monitoringGoalCount: Long) = - monitoringGoalCount(JsonField.of(monitoringGoalCount)) - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - fun links(links: Links) = links(JsonField.of(links)) - - /** Links to the project. */ - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun gitRepo(gitRepo: GitRepo) = gitRepo(JsonField.of(gitRepo)) - - @JsonProperty("gitRepo") - @ExcludeMissing - fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Project = - Project( - id, - workspaceId, - creatorId, - name, - dateCreated, - dateUpdated, - description, - source, - taskType, - versionCount, - inferencePipelineCount, - goalCount, - developmentGoalCount, - monitoringGoalCount, - links, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: JsonField, - private val gitId: JsonField, - private val dateConnected: JsonField, - private val dateUpdated: JsonField, - private val branch: JsonField, - private val name: JsonField, - private val private_: JsonField, - private val slug: JsonField, - private val url: JsonField, - private val rootDir: JsonField, - private val projectId: JsonField, - private val gitAccountId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun gitId(): Long = gitId.getRequired("gitId") - - fun dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - - fun name(): String = name.getRequired("name") - - fun private_(): Boolean = private_.getRequired("private") - - fun slug(): String = slug.getRequired("slug") - - fun url(): String = url.getRequired("url") - - fun rootDir(): Optional = Optional.ofNullable(rootDir.getNullable("rootDir")) - - fun projectId(): String = projectId.getRequired("projectId") - - fun gitAccountId(): String = gitAccountId.getRequired("gitAccountId") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("gitId") @ExcludeMissing fun _gitId() = gitId - - @JsonProperty("dateConnected") @ExcludeMissing fun _dateConnected() = dateConnected - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("private") @ExcludeMissing fun _private_() = private_ - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("rootDir") @ExcludeMissing fun _rootDir() = rootDir - - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("gitAccountId") @ExcludeMissing fun _gitAccountId() = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitRepo = apply { - if (!validated) { - id() - gitId() - dateConnected() - dateUpdated() - branch() - name() - private_() - slug() - url() - rootDir() - projectId() - gitAccountId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var gitId: JsonField = JsonMissing.of() - private var dateConnected: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var private_: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var rootDir: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var gitAccountId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) - - @JsonProperty("gitId") - @ExcludeMissing - fun gitId(gitId: JsonField) = apply { this.gitId = gitId } - - fun dateConnected(dateConnected: OffsetDateTime) = - dateConnected(JsonField.of(dateConnected)) - - @JsonProperty("dateConnected") - @ExcludeMissing - fun dateConnected(dateConnected: JsonField) = apply { - this.dateConnected = dateConnected - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun branch(branch: String) = branch(JsonField.of(branch)) - - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun private_(private_: Boolean) = private_(JsonField.of(private_)) - - @JsonProperty("private") - @ExcludeMissing - fun private_(private_: JsonField) = apply { this.private_ = private_ } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) - - @JsonProperty("rootDir") - @ExcludeMissing - fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) - - @JsonProperty("gitAccountId") - @ExcludeMissing - fun gitAccountId(gitAccountId: JsonField) = apply { - this.gitAccountId = gitAccountId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - id, - gitId, - dateConnected, - dateUpdated, - branch, - name, - private_, - slug, - url, - rootDir, - projectId, - gitAccountId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Project && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Project{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Workspace.Builder::class) - @NoAutoDetect - class Workspace - private constructor( - private val id: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val creatorId: JsonField, - private val inviteCode: JsonField, - private val wildcardDomains: JsonField>, - private val projectCount: JsonField, - private val memberCount: JsonField, - private val monthlyUsage: JsonField>, - private val inviteCount: JsonField, - private val periodStartDate: JsonField, - private val periodEndDate: JsonField, - private val samlOnlyAccess: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - fun slug(): String = slug.getRequired("slug") - - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - fun inviteCode(): Optional = - Optional.ofNullable(inviteCode.getNullable("inviteCode")) - - fun wildcardDomains(): Optional> = - Optional.ofNullable(wildcardDomains.getNullable("wildcardDomains")) - - fun projectCount(): Long = projectCount.getRequired("projectCount") - - fun memberCount(): Long = memberCount.getRequired("memberCount") - - fun monthlyUsage(): Optional> = - Optional.ofNullable(monthlyUsage.getNullable("monthlyUsage")) - - fun inviteCount(): Long = inviteCount.getRequired("inviteCount") - - fun periodStartDate(): Optional = - Optional.ofNullable(periodStartDate.getNullable("periodStartDate")) - - fun periodEndDate(): Optional = - Optional.ofNullable(periodEndDate.getNullable("periodEndDate")) - - fun samlOnlyAccess(): Optional = - Optional.ofNullable(samlOnlyAccess.getNullable("samlOnlyAccess")) - - fun status(): Status = status.getRequired("status") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - @JsonProperty("inviteCode") @ExcludeMissing fun _inviteCode() = inviteCode - - @JsonProperty("wildcardDomains") @ExcludeMissing fun _wildcardDomains() = wildcardDomains - - @JsonProperty("projectCount") @ExcludeMissing fun _projectCount() = projectCount - - @JsonProperty("memberCount") @ExcludeMissing fun _memberCount() = memberCount - - @JsonProperty("monthlyUsage") @ExcludeMissing fun _monthlyUsage() = monthlyUsage - - @JsonProperty("inviteCount") @ExcludeMissing fun _inviteCount() = inviteCount - - @JsonProperty("periodStartDate") @ExcludeMissing fun _periodStartDate() = periodStartDate - - @JsonProperty("periodEndDate") @ExcludeMissing fun _periodEndDate() = periodEndDate - - @JsonProperty("samlOnlyAccess") @ExcludeMissing fun _samlOnlyAccess() = samlOnlyAccess - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Workspace = apply { - if (!validated) { - id() - name() - slug() - dateCreated() - dateUpdated() - creatorId() - inviteCode() - wildcardDomains() - projectCount() - memberCount() - monthlyUsage().map { it.forEach { it.validate() } } - inviteCount() - periodStartDate() - periodEndDate() - samlOnlyAccess() - status() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var inviteCode: JsonField = JsonMissing.of() - private var wildcardDomains: JsonField> = JsonMissing.of() - private var projectCount: JsonField = JsonMissing.of() - private var memberCount: JsonField = JsonMissing.of() - private var monthlyUsage: JsonField> = JsonMissing.of() - private var inviteCount: JsonField = JsonMissing.of() - private var periodStartDate: JsonField = JsonMissing.of() - private var periodEndDate: JsonField = JsonMissing.of() - private var samlOnlyAccess: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(workspace: Workspace) = apply { - this.id = workspace.id - this.name = workspace.name - this.slug = workspace.slug - this.dateCreated = workspace.dateCreated - this.dateUpdated = workspace.dateUpdated - this.creatorId = workspace.creatorId - this.inviteCode = workspace.inviteCode - this.wildcardDomains = workspace.wildcardDomains - this.projectCount = workspace.projectCount - this.memberCount = workspace.memberCount - this.monthlyUsage = workspace.monthlyUsage - this.inviteCount = workspace.inviteCount - this.periodStartDate = workspace.periodStartDate - this.periodEndDate = workspace.periodEndDate - this.samlOnlyAccess = workspace.samlOnlyAccess - this.status = workspace.status - additionalProperties(workspace.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) - - @JsonProperty("inviteCode") - @ExcludeMissing - fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } - - fun wildcardDomains(wildcardDomains: List) = - wildcardDomains(JsonField.of(wildcardDomains)) - - @JsonProperty("wildcardDomains") - @ExcludeMissing - fun wildcardDomains(wildcardDomains: JsonField>) = apply { - this.wildcardDomains = wildcardDomains - } - - fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) - - @JsonProperty("projectCount") - @ExcludeMissing - fun projectCount(projectCount: JsonField) = apply { - this.projectCount = projectCount - } - - fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) - - @JsonProperty("memberCount") - @ExcludeMissing - fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } - - fun monthlyUsage(monthlyUsage: List) = - monthlyUsage(JsonField.of(monthlyUsage)) - - @JsonProperty("monthlyUsage") - @ExcludeMissing - fun monthlyUsage(monthlyUsage: JsonField>) = apply { - this.monthlyUsage = monthlyUsage - } - - fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) - - @JsonProperty("inviteCount") - @ExcludeMissing - fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } - - fun periodStartDate(periodStartDate: OffsetDateTime) = - periodStartDate(JsonField.of(periodStartDate)) - - @JsonProperty("periodStartDate") - @ExcludeMissing - fun periodStartDate(periodStartDate: JsonField) = apply { - this.periodStartDate = periodStartDate - } - - fun periodEndDate(periodEndDate: OffsetDateTime) = - periodEndDate(JsonField.of(periodEndDate)) - - @JsonProperty("periodEndDate") - @ExcludeMissing - fun periodEndDate(periodEndDate: JsonField) = apply { - this.periodEndDate = periodEndDate - } - - fun samlOnlyAccess(samlOnlyAccess: Boolean) = - samlOnlyAccess(JsonField.of(samlOnlyAccess)) - - @JsonProperty("samlOnlyAccess") - @ExcludeMissing - fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { - this.samlOnlyAccess = samlOnlyAccess - } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Workspace = - Workspace( - id, - name, - slug, - dateCreated, - dateUpdated, - creatorId, - inviteCode, - wildcardDomains.map { it.toImmutable() }, - projectCount, - memberCount, - monthlyUsage.map { it.toImmutable() }, - inviteCount, - periodStartDate, - periodEndDate, - samlOnlyAccess, - status, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val PAST_DUE = of("past_due") - - @JvmField val UNPAID = of("unpaid") - - @JvmField val CANCELED = of("canceled") - - @JvmField val INCOMPLETE = of("incomplete") - - @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") - - @JvmField val TRIALING = of("trialing") - - @JvmField val PAUSED = of("paused") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - } - - enum class Value { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - PAST_DUE -> Value.PAST_DUE - UNPAID -> Value.UNPAID - CANCELED -> Value.CANCELED - INCOMPLETE -> Value.INCOMPLETE - INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED - TRIALING -> Value.TRIALING - PAUSED -> Value.PAUSED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - PAST_DUE -> Known.PAST_DUE - UNPAID -> Known.UNPAID - CANCELED -> Known.CANCELED - INCOMPLETE -> Known.INCOMPLETE - INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED - TRIALING -> Known.TRIALING - PAUSED -> Known.PAUSED - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = MonthlyUsage.Builder::class) - @NoAutoDetect - class MonthlyUsage - private constructor( - private val monthYear: JsonField, - private val predictionCount: JsonField, - private val executionTimeMs: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun monthYear(): Optional = - Optional.ofNullable(monthYear.getNullable("monthYear")) - - fun predictionCount(): Optional = - Optional.ofNullable(predictionCount.getNullable("predictionCount")) - - fun executionTimeMs(): Optional = - Optional.ofNullable(executionTimeMs.getNullable("executionTimeMs")) - - @JsonProperty("monthYear") @ExcludeMissing fun _monthYear() = monthYear - - @JsonProperty("predictionCount") - @ExcludeMissing - fun _predictionCount() = predictionCount - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun _executionTimeMs() = executionTimeMs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MonthlyUsage = apply { - if (!validated) { - monthYear() - predictionCount() - executionTimeMs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var monthYear: JsonField = JsonMissing.of() - private var predictionCount: JsonField = JsonMissing.of() - private var executionTimeMs: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monthlyUsage: MonthlyUsage) = apply { - this.monthYear = monthlyUsage.monthYear - this.predictionCount = monthlyUsage.predictionCount - this.executionTimeMs = monthlyUsage.executionTimeMs - additionalProperties(monthlyUsage.additionalProperties) - } - - fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) - - @JsonProperty("monthYear") - @ExcludeMissing - fun monthYear(monthYear: JsonField) = apply { - this.monthYear = monthYear - } - - fun predictionCount(predictionCount: Long) = - predictionCount(JsonField.of(predictionCount)) - - @JsonProperty("predictionCount") - @ExcludeMissing - fun predictionCount(predictionCount: JsonField) = apply { - this.predictionCount = predictionCount - } - - fun executionTimeMs(executionTimeMs: Long) = - executionTimeMs(JsonField.of(executionTimeMs)) - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun executionTimeMs(executionTimeMs: JsonField) = apply { - this.executionTimeMs = executionTimeMs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MonthlyUsage = - MonthlyUsage( - monthYear, - predictionCount, - executionTimeMs, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonthlyUsage && monthYear == other.monthYear && predictionCount == other.predictionCount && executionTimeMs == other.executionTimeMs && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(monthYear, predictionCount, executionTimeMs, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonthlyUsage{monthYear=$monthYear, predictionCount=$predictionCount, executionTimeMs=$executionTimeMs, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Workspace && id == other.id && name == other.name && slug == other.slug && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && creatorId == other.creatorId && inviteCode == other.inviteCode && wildcardDomains == other.wildcardDomains && projectCount == other.projectCount && memberCount == other.memberCount && monthlyUsage == other.monthlyUsage && inviteCount == other.inviteCount && periodStartDate == other.periodStartDate && periodEndDate == other.periodEndDate && samlOnlyAccess == other.samlOnlyAccess && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, slug, dateCreated, dateUpdated, creatorId, inviteCode, wildcardDomains, projectCount, memberCount, monthlyUsage, inviteCount, periodStartDate, periodEndDate, samlOnlyAccess, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Workspace{id=$id, name=$name, slug=$slug, dateCreated=$dateCreated, dateUpdated=$dateUpdated, creatorId=$creatorId, inviteCode=$inviteCode, wildcardDomains=$wildcardDomains, projectCount=$projectCount, memberCount=$memberCount, monthlyUsage=$monthlyUsage, inviteCount=$inviteCount, periodStartDate=$periodStartDate, periodEndDate=$periodEndDate, samlOnlyAccess=$samlOnlyAccess, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectInferencePipelineCreateResponse && id == other.id && projectId == other.projectId && workspaceId == other.workspaceId && project == other.project && workspace == other.workspace && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && dateLastSampleReceived == other.dateLastSampleReceived && description == other.description && dateLastEvaluated == other.dateLastEvaluated && dateOfNextEvaluation == other.dateOfNextEvaluation && passingGoalCount == other.passingGoalCount && failingGoalCount == other.failingGoalCount && totalGoalCount == other.totalGoalCount && status == other.status && statusMessage == other.statusMessage && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, workspaceId, project, workspace, name, dateCreated, dateUpdated, dateLastSampleReceived, description, dateLastEvaluated, dateOfNextEvaluation, passingGoalCount, failingGoalCount, totalGoalCount, status, statusMessage, links, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectInferencePipelineCreateResponse{id=$id, projectId=$projectId, workspaceId=$workspaceId, project=$project, workspace=$workspace, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateLastSampleReceived=$dateLastSampleReceived, description=$description, dateLastEvaluated=$dateLastEvaluated, dateOfNextEvaluation=$dateOfNextEvaluation, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, status=$status, statusMessage=$statusMessage, links=$links, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineListResponse.kt deleted file mode 100644 index 5ee1acf6..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineListResponse.kt +++ /dev/null @@ -1,2190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.LocalDate -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = ProjectInferencePipelineListResponse.Builder::class) -@NoAutoDetect -class ProjectInferencePipelineListResponse -private constructor( - private val items: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun items(): List = items.getRequired("items") - - @JsonProperty("items") @ExcludeMissing fun _items() = items - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectInferencePipelineListResponse = apply { - if (!validated) { - items().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - projectInferencePipelineListResponse: ProjectInferencePipelineListResponse - ) = apply { - this.items = projectInferencePipelineListResponse.items - additionalProperties(projectInferencePipelineListResponse.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - @JsonProperty("items") - @ExcludeMissing - fun items(items: JsonField>) = apply { this.items = items } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectInferencePipelineListResponse = - ProjectInferencePipelineListResponse( - items.map { it.toImmutable() }, - additionalProperties.toImmutable() - ) - } - - @JsonDeserialize(builder = Item.Builder::class) - @NoAutoDetect - class Item - private constructor( - private val id: JsonField, - private val projectId: JsonField, - private val workspaceId: JsonField, - private val project: JsonField, - private val workspace: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val dateLastSampleReceived: JsonField, - private val description: JsonField, - private val dateLastEvaluated: JsonField, - private val dateOfNextEvaluation: JsonField, - private val passingGoalCount: JsonField, - private val failingGoalCount: JsonField, - private val totalGoalCount: JsonField, - private val status: JsonField, - private val statusMessage: JsonField, - private val links: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The inference pipeline id. */ - fun id(): String = id.getRequired("id") - - /** The project id. */ - fun projectId(): String = projectId.getRequired("projectId") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - fun project(): Optional = Optional.ofNullable(project.getNullable("project")) - - fun workspace(): Optional = - Optional.ofNullable(workspace.getNullable("workspace")) - - /** The inference pipeline name. */ - fun name(): String = name.getRequired("name") - - /** The creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The last data sample received date. */ - fun dateLastSampleReceived(): Optional = - Optional.ofNullable(dateLastSampleReceived.getNullable("dateLastSampleReceived")) - - /** The inference pipeline description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The last test evaluation date. */ - fun dateLastEvaluated(): Optional = - Optional.ofNullable(dateLastEvaluated.getNullable("dateLastEvaluated")) - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(): Optional = - Optional.ofNullable(dateOfNextEvaluation.getNullable("dateOfNextEvaluation")) - - /** The number of tests passing. */ - fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") - - /** The number of tests failing. */ - fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") - - /** The total number of tests. */ - fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") - - /** The status of test evaluation for the inference pipeline. */ - fun status(): Status = status.getRequired("status") - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(): Optional = - Optional.ofNullable(statusMessage.getNullable("statusMessage")) - - fun links(): Links = links.getRequired("links") - - /** The inference pipeline id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The project id. */ - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - @JsonProperty("project") @ExcludeMissing fun _project() = project - - @JsonProperty("workspace") @ExcludeMissing fun _workspace() = workspace - - /** The inference pipeline name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun _dateLastSampleReceived() = dateLastSampleReceived - - /** The inference pipeline description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") - @ExcludeMissing - fun _dateLastEvaluated() = dateLastEvaluated - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun _dateOfNextEvaluation() = dateOfNextEvaluation - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage - - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Item = apply { - if (!validated) { - id() - projectId() - workspaceId() - project().map { it.validate() } - workspace().map { it.validate() } - name() - dateCreated() - dateUpdated() - dateLastSampleReceived() - description() - dateLastEvaluated() - dateOfNextEvaluation() - passingGoalCount() - failingGoalCount() - totalGoalCount() - status() - statusMessage() - links().validate() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var project: JsonField = JsonMissing.of() - private var workspace: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var dateLastSampleReceived: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dateLastEvaluated: JsonField = JsonMissing.of() - private var dateOfNextEvaluation: JsonField = JsonMissing.of() - private var passingGoalCount: JsonField = JsonMissing.of() - private var failingGoalCount: JsonField = JsonMissing.of() - private var totalGoalCount: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusMessage: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - this.id = item.id - this.projectId = item.projectId - this.workspaceId = item.workspaceId - this.project = item.project - this.workspace = item.workspace - this.name = item.name - this.dateCreated = item.dateCreated - this.dateUpdated = item.dateUpdated - this.dateLastSampleReceived = item.dateLastSampleReceived - this.description = item.description - this.dateLastEvaluated = item.dateLastEvaluated - this.dateOfNextEvaluation = item.dateOfNextEvaluation - this.passingGoalCount = item.passingGoalCount - this.failingGoalCount = item.failingGoalCount - this.totalGoalCount = item.totalGoalCount - this.status = item.status - this.statusMessage = item.statusMessage - this.links = item.links - additionalProperties(item.additionalProperties) - } - - /** The inference pipeline id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The inference pipeline id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The project id. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** The project id. */ - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { - this.workspaceId = workspaceId - } - - fun project(project: Project) = project(JsonField.of(project)) - - @JsonProperty("project") - @ExcludeMissing - fun project(project: JsonField) = apply { this.project = project } - - fun workspace(workspace: Workspace) = workspace(JsonField.of(workspace)) - - @JsonProperty("workspace") - @ExcludeMissing - fun workspace(workspace: JsonField) = apply { this.workspace = workspace } - - /** The inference pipeline name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The inference pipeline name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The last data sample received date. */ - fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime) = - dateLastSampleReceived(JsonField.of(dateLastSampleReceived)) - - /** The last data sample received date. */ - @JsonProperty("dateLastSampleReceived") - @ExcludeMissing - fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { - this.dateLastSampleReceived = dateLastSampleReceived - } - - /** The inference pipeline description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The inference pipeline description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - /** The last test evaluation date. */ - fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime) = - dateLastEvaluated(JsonField.of(dateLastEvaluated)) - - /** The last test evaluation date. */ - @JsonProperty("dateLastEvaluated") - @ExcludeMissing - fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { - this.dateLastEvaluated = dateLastEvaluated - } - - /** The next test evaluation date. */ - fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime) = - dateOfNextEvaluation(JsonField.of(dateOfNextEvaluation)) - - /** The next test evaluation date. */ - @JsonProperty("dateOfNextEvaluation") - @ExcludeMissing - fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { - this.dateOfNextEvaluation = dateOfNextEvaluation - } - - /** The number of tests passing. */ - fun passingGoalCount(passingGoalCount: Long) = - passingGoalCount(JsonField.of(passingGoalCount)) - - /** The number of tests passing. */ - @JsonProperty("passingGoalCount") - @ExcludeMissing - fun passingGoalCount(passingGoalCount: JsonField) = apply { - this.passingGoalCount = passingGoalCount - } - - /** The number of tests failing. */ - fun failingGoalCount(failingGoalCount: Long) = - failingGoalCount(JsonField.of(failingGoalCount)) - - /** The number of tests failing. */ - @JsonProperty("failingGoalCount") - @ExcludeMissing - fun failingGoalCount(failingGoalCount: JsonField) = apply { - this.failingGoalCount = failingGoalCount - } - - /** The total number of tests. */ - fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) - - /** The total number of tests. */ - @JsonProperty("totalGoalCount") - @ExcludeMissing - fun totalGoalCount(totalGoalCount: JsonField) = apply { - this.totalGoalCount = totalGoalCount - } - - /** The status of test evaluation for the inference pipeline. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** The status of test evaluation for the inference pipeline. */ - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - /** The status message of test evaluation for the inference pipeline. */ - fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) - - /** The status message of test evaluation for the inference pipeline. */ - @JsonProperty("statusMessage") - @ExcludeMissing - fun statusMessage(statusMessage: JsonField) = apply { - this.statusMessage = statusMessage - } - - fun links(links: Links) = links(JsonField.of(links)) - - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Item = - Item( - id, - projectId, - workspaceId, - project, - workspace, - name, - dateCreated, - dateUpdated, - dateLastSampleReceived, - description, - dateLastEvaluated, - dateOfNextEvaluation, - passingGoalCount, - failingGoalCount, - totalGoalCount, - status, - statusMessage, - links, - additionalProperties.toImmutable(), - ) - } - - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUEUED = of("queued") - - @JvmField val RUNNING = of("running") - - @JvmField val PAUSED = of("paused") - - @JvmField val FAILED = of("failed") - - @JvmField val COMPLETED = of("completed") - - @JvmField val UNKNOWN = of("unknown") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - } - - enum class Value { - QUEUED, - RUNNING, - PAUSED, - FAILED, - COMPLETED, - UNKNOWN, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - QUEUED -> Value.QUEUED - RUNNING -> Value.RUNNING - PAUSED -> Value.PAUSED - FAILED -> Value.FAILED - COMPLETED -> Value.COMPLETED - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - QUEUED -> Known.QUEUED - RUNNING -> Known.RUNNING - PAUSED -> Known.PAUSED - FAILED -> Known.FAILED - COMPLETED -> Known.COMPLETED - UNKNOWN -> Known.UNKNOWN - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = Project.Builder::class) - @NoAutoDetect - class Project - private constructor( - private val id: JsonField, - private val workspaceId: JsonField, - private val creatorId: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonField, - private val source: JsonField, - private val taskType: JsonField, - private val versionCount: JsonField, - private val inferencePipelineCount: JsonField, - private val goalCount: JsonField, - private val developmentGoalCount: JsonField, - private val monitoringGoalCount: JsonField, - private val links: JsonField, - private val gitRepo: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The project id. */ - fun id(): String = id.getRequired("id") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - /** The project creator id. */ - fun creatorId(): Optional = - Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project name. */ - fun name(): String = name.getRequired("name") - - /** The project creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The project last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The project description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The source of the project. */ - fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - - /** The task type of the project. */ - fun taskType(): TaskType = taskType.getRequired("taskType") - - /** The number of versions (commits) in the project. */ - fun versionCount(): Long = versionCount.getRequired("versionCount") - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(): Long = - inferencePipelineCount.getRequired("inferencePipelineCount") - - /** The total number of tests in the project. */ - fun goalCount(): Long = goalCount.getRequired("goalCount") - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(): Long = - developmentGoalCount.getRequired("developmentGoalCount") - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") - - /** Links to the project. */ - fun links(): Links = links.getRequired("links") - - fun gitRepo(): Optional = Optional.ofNullable(gitRepo.getNullable("gitRepo")) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The project creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The project description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The source of the project. */ - @JsonProperty("source") @ExcludeMissing fun _source() = source - - /** The task type of the project. */ - @JsonProperty("taskType") @ExcludeMissing fun _taskType() = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") @ExcludeMissing fun _versionCount() = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun _inferencePipelineCount() = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") @ExcludeMissing fun _goalCount() = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun _developmentGoalCount() = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun _monitoringGoalCount() = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo() = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Project = apply { - if (!validated) { - id() - workspaceId() - creatorId() - name() - dateCreated() - dateUpdated() - description() - source() - taskType() - versionCount() - inferencePipelineCount() - goalCount() - developmentGoalCount() - monitoringGoalCount() - links().validate() - gitRepo().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var taskType: JsonField = JsonMissing.of() - private var versionCount: JsonField = JsonMissing.of() - private var inferencePipelineCount: JsonField = JsonMissing.of() - private var goalCount: JsonField = JsonMissing.of() - private var developmentGoalCount: JsonField = JsonMissing.of() - private var monitoringGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var gitRepo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(project: Project) = apply { - this.id = project.id - this.workspaceId = project.workspaceId - this.creatorId = project.creatorId - this.name = project.name - this.dateCreated = project.dateCreated - this.dateUpdated = project.dateUpdated - this.description = project.description - this.source = project.source - this.taskType = project.taskType - this.versionCount = project.versionCount - this.inferencePipelineCount = project.inferencePipelineCount - this.goalCount = project.goalCount - this.developmentGoalCount = project.developmentGoalCount - this.monitoringGoalCount = project.monitoringGoalCount - this.links = project.links - this.gitRepo = project.gitRepo - additionalProperties(project.additionalProperties) - } - - /** The project id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { - this.workspaceId = workspaceId - } - - /** The project creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The project creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The project name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The project creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = - dateCreated(JsonField.of(dateCreated)) - - /** The project creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The project last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The project description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The project description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - /** The source of the project. */ - fun source(source: Source) = source(JsonField.of(source)) - - /** The source of the project. */ - @JsonProperty("source") - @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) - - /** The task type of the project. */ - @JsonProperty("taskType") - @ExcludeMissing - fun taskType(taskType: JsonField) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - @ExcludeMissing - fun versionCount(versionCount: JsonField) = apply { - this.versionCount = versionCount - } - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(inferencePipelineCount: Long) = - inferencePipelineCount(JsonField.of(inferencePipelineCount)) - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - @ExcludeMissing - fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(developmentGoalCount: Long) = - developmentGoalCount(JsonField.of(developmentGoalCount)) - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun developmentGoalCount(developmentGoalCount: JsonField) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(monitoringGoalCount: Long) = - monitoringGoalCount(JsonField.of(monitoringGoalCount)) - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - fun links(links: Links) = links(JsonField.of(links)) - - /** Links to the project. */ - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun gitRepo(gitRepo: GitRepo) = gitRepo(JsonField.of(gitRepo)) - - @JsonProperty("gitRepo") - @ExcludeMissing - fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Project = - Project( - id, - workspaceId, - creatorId, - name, - dateCreated, - dateUpdated, - description, - source, - taskType, - versionCount, - inferencePipelineCount, - goalCount, - developmentGoalCount, - monitoringGoalCount, - links, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: JsonField, - private val gitId: JsonField, - private val dateConnected: JsonField, - private val dateUpdated: JsonField, - private val branch: JsonField, - private val name: JsonField, - private val private_: JsonField, - private val slug: JsonField, - private val url: JsonField, - private val rootDir: JsonField, - private val projectId: JsonField, - private val gitAccountId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun gitId(): Long = gitId.getRequired("gitId") - - fun dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - - fun name(): String = name.getRequired("name") - - fun private_(): Boolean = private_.getRequired("private") - - fun slug(): String = slug.getRequired("slug") - - fun url(): String = url.getRequired("url") - - fun rootDir(): Optional = - Optional.ofNullable(rootDir.getNullable("rootDir")) - - fun projectId(): String = projectId.getRequired("projectId") - - fun gitAccountId(): String = gitAccountId.getRequired("gitAccountId") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("gitId") @ExcludeMissing fun _gitId() = gitId - - @JsonProperty("dateConnected") @ExcludeMissing fun _dateConnected() = dateConnected - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("private") @ExcludeMissing fun _private_() = private_ - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("rootDir") @ExcludeMissing fun _rootDir() = rootDir - - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("gitAccountId") @ExcludeMissing fun _gitAccountId() = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitRepo = apply { - if (!validated) { - id() - gitId() - dateConnected() - dateUpdated() - branch() - name() - private_() - slug() - url() - rootDir() - projectId() - gitAccountId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var gitId: JsonField = JsonMissing.of() - private var dateConnected: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var private_: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var rootDir: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var gitAccountId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) - - @JsonProperty("gitId") - @ExcludeMissing - fun gitId(gitId: JsonField) = apply { this.gitId = gitId } - - fun dateConnected(dateConnected: OffsetDateTime) = - dateConnected(JsonField.of(dateConnected)) - - @JsonProperty("dateConnected") - @ExcludeMissing - fun dateConnected(dateConnected: JsonField) = apply { - this.dateConnected = dateConnected - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun branch(branch: String) = branch(JsonField.of(branch)) - - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun private_(private_: Boolean) = private_(JsonField.of(private_)) - - @JsonProperty("private") - @ExcludeMissing - fun private_(private_: JsonField) = apply { this.private_ = private_ } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) - - @JsonProperty("rootDir") - @ExcludeMissing - fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { - this.projectId = projectId - } - - fun gitAccountId(gitAccountId: String) = - gitAccountId(JsonField.of(gitAccountId)) - - @JsonProperty("gitAccountId") - @ExcludeMissing - fun gitAccountId(gitAccountId: JsonField) = apply { - this.gitAccountId = gitAccountId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - id, - gitId, - dateConnected, - dateUpdated, - branch, - name, - private_, - slug, - url, - rootDir, - projectId, - gitAccountId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Project && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Project{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" - } - - @JsonDeserialize(builder = Workspace.Builder::class) - @NoAutoDetect - class Workspace - private constructor( - private val id: JsonField, - private val name: JsonField, - private val slug: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val creatorId: JsonField, - private val inviteCode: JsonField, - private val wildcardDomains: JsonField>, - private val projectCount: JsonField, - private val memberCount: JsonField, - private val monthlyUsage: JsonField>, - private val inviteCount: JsonField, - private val periodStartDate: JsonField, - private val periodEndDate: JsonField, - private val samlOnlyAccess: JsonField, - private val status: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun name(): String = name.getRequired("name") - - fun slug(): String = slug.getRequired("slug") - - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun creatorId(): Optional = - Optional.ofNullable(creatorId.getNullable("creatorId")) - - fun inviteCode(): Optional = - Optional.ofNullable(inviteCode.getNullable("inviteCode")) - - fun wildcardDomains(): Optional> = - Optional.ofNullable(wildcardDomains.getNullable("wildcardDomains")) - - fun projectCount(): Long = projectCount.getRequired("projectCount") - - fun memberCount(): Long = memberCount.getRequired("memberCount") - - fun monthlyUsage(): Optional> = - Optional.ofNullable(monthlyUsage.getNullable("monthlyUsage")) - - fun inviteCount(): Long = inviteCount.getRequired("inviteCount") - - fun periodStartDate(): Optional = - Optional.ofNullable(periodStartDate.getNullable("periodStartDate")) - - fun periodEndDate(): Optional = - Optional.ofNullable(periodEndDate.getNullable("periodEndDate")) - - fun samlOnlyAccess(): Optional = - Optional.ofNullable(samlOnlyAccess.getNullable("samlOnlyAccess")) - - fun status(): Status = status.getRequired("status") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - @JsonProperty("inviteCode") @ExcludeMissing fun _inviteCode() = inviteCode - - @JsonProperty("wildcardDomains") - @ExcludeMissing - fun _wildcardDomains() = wildcardDomains - - @JsonProperty("projectCount") @ExcludeMissing fun _projectCount() = projectCount - - @JsonProperty("memberCount") @ExcludeMissing fun _memberCount() = memberCount - - @JsonProperty("monthlyUsage") @ExcludeMissing fun _monthlyUsage() = monthlyUsage - - @JsonProperty("inviteCount") @ExcludeMissing fun _inviteCount() = inviteCount - - @JsonProperty("periodStartDate") - @ExcludeMissing - fun _periodStartDate() = periodStartDate - - @JsonProperty("periodEndDate") @ExcludeMissing fun _periodEndDate() = periodEndDate - - @JsonProperty("samlOnlyAccess") @ExcludeMissing fun _samlOnlyAccess() = samlOnlyAccess - - @JsonProperty("status") @ExcludeMissing fun _status() = status - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Workspace = apply { - if (!validated) { - id() - name() - slug() - dateCreated() - dateUpdated() - creatorId() - inviteCode() - wildcardDomains() - projectCount() - memberCount() - monthlyUsage().map { it.forEach { it.validate() } } - inviteCount() - periodStartDate() - periodEndDate() - samlOnlyAccess() - status() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var inviteCode: JsonField = JsonMissing.of() - private var wildcardDomains: JsonField> = JsonMissing.of() - private var projectCount: JsonField = JsonMissing.of() - private var memberCount: JsonField = JsonMissing.of() - private var monthlyUsage: JsonField> = JsonMissing.of() - private var inviteCount: JsonField = JsonMissing.of() - private var periodStartDate: JsonField = JsonMissing.of() - private var periodEndDate: JsonField = JsonMissing.of() - private var samlOnlyAccess: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(workspace: Workspace) = apply { - this.id = workspace.id - this.name = workspace.name - this.slug = workspace.slug - this.dateCreated = workspace.dateCreated - this.dateUpdated = workspace.dateUpdated - this.creatorId = workspace.creatorId - this.inviteCode = workspace.inviteCode - this.wildcardDomains = workspace.wildcardDomains - this.projectCount = workspace.projectCount - this.memberCount = workspace.memberCount - this.monthlyUsage = workspace.monthlyUsage - this.inviteCount = workspace.inviteCount - this.periodStartDate = workspace.periodStartDate - this.periodEndDate = workspace.periodEndDate - this.samlOnlyAccess = workspace.samlOnlyAccess - this.status = workspace.status - additionalProperties(workspace.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun dateCreated(dateCreated: OffsetDateTime) = - dateCreated(JsonField.of(dateCreated)) - - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) - - @JsonProperty("inviteCode") - @ExcludeMissing - fun inviteCode(inviteCode: JsonField) = apply { - this.inviteCode = inviteCode - } - - fun wildcardDomains(wildcardDomains: List) = - wildcardDomains(JsonField.of(wildcardDomains)) - - @JsonProperty("wildcardDomains") - @ExcludeMissing - fun wildcardDomains(wildcardDomains: JsonField>) = apply { - this.wildcardDomains = wildcardDomains - } - - fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) - - @JsonProperty("projectCount") - @ExcludeMissing - fun projectCount(projectCount: JsonField) = apply { - this.projectCount = projectCount - } - - fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) - - @JsonProperty("memberCount") - @ExcludeMissing - fun memberCount(memberCount: JsonField) = apply { - this.memberCount = memberCount - } - - fun monthlyUsage(monthlyUsage: List) = - monthlyUsage(JsonField.of(monthlyUsage)) - - @JsonProperty("monthlyUsage") - @ExcludeMissing - fun monthlyUsage(monthlyUsage: JsonField>) = apply { - this.monthlyUsage = monthlyUsage - } - - fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) - - @JsonProperty("inviteCount") - @ExcludeMissing - fun inviteCount(inviteCount: JsonField) = apply { - this.inviteCount = inviteCount - } - - fun periodStartDate(periodStartDate: OffsetDateTime) = - periodStartDate(JsonField.of(periodStartDate)) - - @JsonProperty("periodStartDate") - @ExcludeMissing - fun periodStartDate(periodStartDate: JsonField) = apply { - this.periodStartDate = periodStartDate - } - - fun periodEndDate(periodEndDate: OffsetDateTime) = - periodEndDate(JsonField.of(periodEndDate)) - - @JsonProperty("periodEndDate") - @ExcludeMissing - fun periodEndDate(periodEndDate: JsonField) = apply { - this.periodEndDate = periodEndDate - } - - fun samlOnlyAccess(samlOnlyAccess: Boolean) = - samlOnlyAccess(JsonField.of(samlOnlyAccess)) - - @JsonProperty("samlOnlyAccess") - @ExcludeMissing - fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { - this.samlOnlyAccess = samlOnlyAccess - } - - fun status(status: Status) = status(JsonField.of(status)) - - @JsonProperty("status") - @ExcludeMissing - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Workspace = - Workspace( - id, - name, - slug, - dateCreated, - dateUpdated, - creatorId, - inviteCode, - wildcardDomains.map { it.toImmutable() }, - projectCount, - memberCount, - monthlyUsage.map { it.toImmutable() }, - inviteCount, - periodStartDate, - periodEndDate, - samlOnlyAccess, - status, - additionalProperties.toImmutable(), - ) - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val PAST_DUE = of("past_due") - - @JvmField val UNPAID = of("unpaid") - - @JvmField val CANCELED = of("canceled") - - @JvmField val INCOMPLETE = of("incomplete") - - @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") - - @JvmField val TRIALING = of("trialing") - - @JvmField val PAUSED = of("paused") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - enum class Known { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - } - - enum class Value { - ACTIVE, - PAST_DUE, - UNPAID, - CANCELED, - INCOMPLETE, - INCOMPLETE_EXPIRED, - TRIALING, - PAUSED, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - PAST_DUE -> Value.PAST_DUE - UNPAID -> Value.UNPAID - CANCELED -> Value.CANCELED - INCOMPLETE -> Value.INCOMPLETE - INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED - TRIALING -> Value.TRIALING - PAUSED -> Value.PAUSED - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - PAST_DUE -> Known.PAST_DUE - UNPAID -> Known.UNPAID - CANCELED -> Known.CANCELED - INCOMPLETE -> Known.INCOMPLETE - INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED - TRIALING -> Known.TRIALING - PAUSED -> Known.PAUSED - else -> throw OpenlayerInvalidDataException("Unknown Status: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = MonthlyUsage.Builder::class) - @NoAutoDetect - class MonthlyUsage - private constructor( - private val monthYear: JsonField, - private val predictionCount: JsonField, - private val executionTimeMs: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun monthYear(): Optional = - Optional.ofNullable(monthYear.getNullable("monthYear")) - - fun predictionCount(): Optional = - Optional.ofNullable(predictionCount.getNullable("predictionCount")) - - fun executionTimeMs(): Optional = - Optional.ofNullable(executionTimeMs.getNullable("executionTimeMs")) - - @JsonProperty("monthYear") @ExcludeMissing fun _monthYear() = monthYear - - @JsonProperty("predictionCount") - @ExcludeMissing - fun _predictionCount() = predictionCount - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun _executionTimeMs() = executionTimeMs - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): MonthlyUsage = apply { - if (!validated) { - monthYear() - predictionCount() - executionTimeMs() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var monthYear: JsonField = JsonMissing.of() - private var predictionCount: JsonField = JsonMissing.of() - private var executionTimeMs: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(monthlyUsage: MonthlyUsage) = apply { - this.monthYear = monthlyUsage.monthYear - this.predictionCount = monthlyUsage.predictionCount - this.executionTimeMs = monthlyUsage.executionTimeMs - additionalProperties(monthlyUsage.additionalProperties) - } - - fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) - - @JsonProperty("monthYear") - @ExcludeMissing - fun monthYear(monthYear: JsonField) = apply { - this.monthYear = monthYear - } - - fun predictionCount(predictionCount: Long) = - predictionCount(JsonField.of(predictionCount)) - - @JsonProperty("predictionCount") - @ExcludeMissing - fun predictionCount(predictionCount: JsonField) = apply { - this.predictionCount = predictionCount - } - - fun executionTimeMs(executionTimeMs: Long) = - executionTimeMs(JsonField.of(executionTimeMs)) - - @JsonProperty("executionTimeMs") - @ExcludeMissing - fun executionTimeMs(executionTimeMs: JsonField) = apply { - this.executionTimeMs = executionTimeMs - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): MonthlyUsage = - MonthlyUsage( - monthYear, - predictionCount, - executionTimeMs, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonthlyUsage && monthYear == other.monthYear && predictionCount == other.predictionCount && executionTimeMs == other.executionTimeMs && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(monthYear, predictionCount, executionTimeMs, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonthlyUsage{monthYear=$monthYear, predictionCount=$predictionCount, executionTimeMs=$executionTimeMs, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Workspace && id == other.id && name == other.name && slug == other.slug && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && creatorId == other.creatorId && inviteCode == other.inviteCode && wildcardDomains == other.wildcardDomains && projectCount == other.projectCount && memberCount == other.memberCount && monthlyUsage == other.monthlyUsage && inviteCount == other.inviteCount && periodStartDate == other.periodStartDate && periodEndDate == other.periodEndDate && samlOnlyAccess == other.samlOnlyAccess && status == other.status && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, name, slug, dateCreated, dateUpdated, creatorId, inviteCode, wildcardDomains, projectCount, memberCount, monthlyUsage, inviteCount, periodStartDate, periodEndDate, samlOnlyAccess, status, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Workspace{id=$id, name=$name, slug=$slug, dateCreated=$dateCreated, dateUpdated=$dateUpdated, creatorId=$creatorId, inviteCode=$inviteCode, wildcardDomains=$wildcardDomains, projectCount=$projectCount, memberCount=$memberCount, monthlyUsage=$monthlyUsage, inviteCount=$inviteCount, periodStartDate=$periodStartDate, periodEndDate=$periodEndDate, samlOnlyAccess=$samlOnlyAccess, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && projectId == other.projectId && workspaceId == other.workspaceId && project == other.project && workspace == other.workspace && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && dateLastSampleReceived == other.dateLastSampleReceived && description == other.description && dateLastEvaluated == other.dateLastEvaluated && dateOfNextEvaluation == other.dateOfNextEvaluation && passingGoalCount == other.passingGoalCount && failingGoalCount == other.failingGoalCount && totalGoalCount == other.totalGoalCount && status == other.status && statusMessage == other.statusMessage && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, projectId, workspaceId, project, workspace, name, dateCreated, dateUpdated, dateLastSampleReceived, description, dateLastEvaluated, dateOfNextEvaluation, passingGoalCount, failingGoalCount, totalGoalCount, status, statusMessage, links, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, projectId=$projectId, workspaceId=$workspaceId, project=$project, workspace=$workspace, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateLastSampleReceived=$dateLastSampleReceived, description=$description, dateLastEvaluated=$dateLastEvaluated, dateOfNextEvaluation=$dateOfNextEvaluation, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, status=$status, statusMessage=$statusMessage, links=$links, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectInferencePipelineListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectInferencePipelineListResponse{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectListResponse.kt deleted file mode 100644 index df9e294c..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectListResponse.kt +++ /dev/null @@ -1,985 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.Enum -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import com.openlayer.api.errors.OpenlayerInvalidDataException -import java.time.OffsetDateTime -import java.util.Objects -import java.util.Optional - -@JsonDeserialize(builder = ProjectListResponse.Builder::class) -@NoAutoDetect -class ProjectListResponse -private constructor( - private val items: JsonField>, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - fun items(): List = items.getRequired("items") - - @JsonProperty("items") @ExcludeMissing fun _items() = items - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): ProjectListResponse = apply { - if (!validated) { - items().forEach { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(projectListResponse: ProjectListResponse) = apply { - this.items = projectListResponse.items - additionalProperties(projectListResponse.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - @JsonProperty("items") - @ExcludeMissing - fun items(items: JsonField>) = apply { this.items = items } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ProjectListResponse = - ProjectListResponse(items.map { it.toImmutable() }, additionalProperties.toImmutable()) - } - - @JsonDeserialize(builder = Item.Builder::class) - @NoAutoDetect - class Item - private constructor( - private val id: JsonField, - private val workspaceId: JsonField, - private val creatorId: JsonField, - private val name: JsonField, - private val dateCreated: JsonField, - private val dateUpdated: JsonField, - private val description: JsonField, - private val source: JsonField, - private val taskType: JsonField, - private val versionCount: JsonField, - private val inferencePipelineCount: JsonField, - private val goalCount: JsonField, - private val developmentGoalCount: JsonField, - private val monitoringGoalCount: JsonField, - private val links: JsonField, - private val gitRepo: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - /** The project id. */ - fun id(): String = id.getRequired("id") - - /** The workspace id. */ - fun workspaceId(): Optional = - Optional.ofNullable(workspaceId.getNullable("workspaceId")) - - /** The project creator id. */ - fun creatorId(): Optional = Optional.ofNullable(creatorId.getNullable("creatorId")) - - /** The project name. */ - fun name(): String = name.getRequired("name") - - /** The project creation date. */ - fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") - - /** The project last updated date. */ - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - /** The project description. */ - fun description(): Optional = - Optional.ofNullable(description.getNullable("description")) - - /** The source of the project. */ - fun source(): Optional = Optional.ofNullable(source.getNullable("source")) - - /** The task type of the project. */ - fun taskType(): TaskType = taskType.getRequired("taskType") - - /** The number of versions (commits) in the project. */ - fun versionCount(): Long = versionCount.getRequired("versionCount") - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(): Long = - inferencePipelineCount.getRequired("inferencePipelineCount") - - /** The total number of tests in the project. */ - fun goalCount(): Long = goalCount.getRequired("goalCount") - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") - - /** Links to the project. */ - fun links(): Links = links.getRequired("links") - - fun gitRepo(): Optional = Optional.ofNullable(gitRepo.getNullable("gitRepo")) - - /** The project id. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id - - /** The workspace id. */ - @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId() = workspaceId - - /** The project creator id. */ - @JsonProperty("creatorId") @ExcludeMissing fun _creatorId() = creatorId - - /** The project name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name - - /** The project creation date. */ - @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated - - /** The project last updated date. */ - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - /** The project description. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description - - /** The source of the project. */ - @JsonProperty("source") @ExcludeMissing fun _source() = source - - /** The task type of the project. */ - @JsonProperty("taskType") @ExcludeMissing fun _taskType() = taskType - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") @ExcludeMissing fun _versionCount() = versionCount - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun _inferencePipelineCount() = inferencePipelineCount - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") @ExcludeMissing fun _goalCount() = goalCount - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun _developmentGoalCount() = developmentGoalCount - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun _monitoringGoalCount() = monitoringGoalCount - - /** Links to the project. */ - @JsonProperty("links") @ExcludeMissing fun _links() = links - - @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo() = gitRepo - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Item = apply { - if (!validated) { - id() - workspaceId() - creatorId() - name() - dateCreated() - dateUpdated() - description() - source() - taskType() - versionCount() - inferencePipelineCount() - goalCount() - developmentGoalCount() - monitoringGoalCount() - links().validate() - gitRepo().map { it.validate() } - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var workspaceId: JsonField = JsonMissing.of() - private var creatorId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var dateCreated: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var taskType: JsonField = JsonMissing.of() - private var versionCount: JsonField = JsonMissing.of() - private var inferencePipelineCount: JsonField = JsonMissing.of() - private var goalCount: JsonField = JsonMissing.of() - private var developmentGoalCount: JsonField = JsonMissing.of() - private var monitoringGoalCount: JsonField = JsonMissing.of() - private var links: JsonField = JsonMissing.of() - private var gitRepo: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - this.id = item.id - this.workspaceId = item.workspaceId - this.creatorId = item.creatorId - this.name = item.name - this.dateCreated = item.dateCreated - this.dateUpdated = item.dateUpdated - this.description = item.description - this.source = item.source - this.taskType = item.taskType - this.versionCount = item.versionCount - this.inferencePipelineCount = item.inferencePipelineCount - this.goalCount = item.goalCount - this.developmentGoalCount = item.developmentGoalCount - this.monitoringGoalCount = item.monitoringGoalCount - this.links = item.links - this.gitRepo = item.gitRepo - additionalProperties(item.additionalProperties) - } - - /** The project id. */ - fun id(id: String) = id(JsonField.of(id)) - - /** The project id. */ - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - /** The workspace id. */ - fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) - - /** The workspace id. */ - @JsonProperty("workspaceId") - @ExcludeMissing - fun workspaceId(workspaceId: JsonField) = apply { - this.workspaceId = workspaceId - } - - /** The project creator id. */ - fun creatorId(creatorId: String) = creatorId(JsonField.of(creatorId)) - - /** The project creator id. */ - @JsonProperty("creatorId") - @ExcludeMissing - fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } - - /** The project name. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The project name. */ - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - /** The project creation date. */ - fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) - - /** The project creation date. */ - @JsonProperty("dateCreated") - @ExcludeMissing - fun dateCreated(dateCreated: JsonField) = apply { - this.dateCreated = dateCreated - } - - /** The project last updated date. */ - fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) - - /** The project last updated date. */ - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - /** The project description. */ - fun description(description: String) = description(JsonField.of(description)) - - /** The project description. */ - @JsonProperty("description") - @ExcludeMissing - fun description(description: JsonField) = apply { - this.description = description - } - - /** The source of the project. */ - fun source(source: Source) = source(JsonField.of(source)) - - /** The source of the project. */ - @JsonProperty("source") - @ExcludeMissing - fun source(source: JsonField) = apply { this.source = source } - - /** The task type of the project. */ - fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) - - /** The task type of the project. */ - @JsonProperty("taskType") - @ExcludeMissing - fun taskType(taskType: JsonField) = apply { this.taskType = taskType } - - /** The number of versions (commits) in the project. */ - fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) - - /** The number of versions (commits) in the project. */ - @JsonProperty("versionCount") - @ExcludeMissing - fun versionCount(versionCount: JsonField) = apply { - this.versionCount = versionCount - } - - /** The number of inference pipelines in the project. */ - fun inferencePipelineCount(inferencePipelineCount: Long) = - inferencePipelineCount(JsonField.of(inferencePipelineCount)) - - /** The number of inference pipelines in the project. */ - @JsonProperty("inferencePipelineCount") - @ExcludeMissing - fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { - this.inferencePipelineCount = inferencePipelineCount - } - - /** The total number of tests in the project. */ - fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) - - /** The total number of tests in the project. */ - @JsonProperty("goalCount") - @ExcludeMissing - fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } - - /** The number of tests in the development mode of the project. */ - fun developmentGoalCount(developmentGoalCount: Long) = - developmentGoalCount(JsonField.of(developmentGoalCount)) - - /** The number of tests in the development mode of the project. */ - @JsonProperty("developmentGoalCount") - @ExcludeMissing - fun developmentGoalCount(developmentGoalCount: JsonField) = apply { - this.developmentGoalCount = developmentGoalCount - } - - /** The number of tests in the monitoring mode of the project. */ - fun monitoringGoalCount(monitoringGoalCount: Long) = - monitoringGoalCount(JsonField.of(monitoringGoalCount)) - - /** The number of tests in the monitoring mode of the project. */ - @JsonProperty("monitoringGoalCount") - @ExcludeMissing - fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { - this.monitoringGoalCount = monitoringGoalCount - } - - /** Links to the project. */ - fun links(links: Links) = links(JsonField.of(links)) - - /** Links to the project. */ - @JsonProperty("links") - @ExcludeMissing - fun links(links: JsonField) = apply { this.links = links } - - fun gitRepo(gitRepo: GitRepo) = gitRepo(JsonField.of(gitRepo)) - - @JsonProperty("gitRepo") - @ExcludeMissing - fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Item = - Item( - id, - workspaceId, - creatorId, - name, - dateCreated, - dateUpdated, - description, - source, - taskType, - versionCount, - inferencePipelineCount, - goalCount, - developmentGoalCount, - monitoringGoalCount, - links, - gitRepo, - additionalProperties.toImmutable(), - ) - } - - /** Links to the project. */ - @JsonDeserialize(builder = Links.Builder::class) - @NoAutoDetect - class Links - private constructor( - private val app: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun app(): String = app.getRequired("app") - - @JsonProperty("app") @ExcludeMissing fun _app() = app - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): Links = apply { - if (!validated) { - app() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var app: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(links: Links) = apply { - this.app = links.app - additionalProperties(links.additionalProperties) - } - - fun app(app: String) = app(JsonField.of(app)) - - @JsonProperty("app") - @ExcludeMissing - fun app(app: JsonField) = apply { this.app = app } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): Links = Links(app, additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" - } - - class Source - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val WEB = of("web") - - @JvmField val API = of("api") - - @JvmField val NULL = of("null") - - @JvmStatic fun of(value: String) = Source(JsonField.of(value)) - } - - enum class Known { - WEB, - API, - NULL, - } - - enum class Value { - WEB, - API, - NULL, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - WEB -> Value.WEB - API -> Value.API - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - WEB -> Known.WEB - API -> Known.API - NULL -> Known.NULL - else -> throw OpenlayerInvalidDataException("Unknown Source: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Source && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LLM_BASE = of("llm-base") - - @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") - - @JvmField val TABULAR_REGRESSION = of("tabular-regression") - - @JvmField val TEXT_CLASSIFICATION = of("text-classification") - - @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) - } - - enum class Known { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - } - - enum class Value { - LLM_BASE, - TABULAR_CLASSIFICATION, - TABULAR_REGRESSION, - TEXT_CLASSIFICATION, - _UNKNOWN, - } - - fun value(): Value = - when (this) { - LLM_BASE -> Value.LLM_BASE - TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Value.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION - else -> Value._UNKNOWN - } - - fun known(): Known = - when (this) { - LLM_BASE -> Known.LLM_BASE - TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION - TABULAR_REGRESSION -> Known.TABULAR_REGRESSION - TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION - else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") - } - - fun asString(): String = _value().asStringOrThrow() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(builder = GitRepo.Builder::class) - @NoAutoDetect - class GitRepo - private constructor( - private val id: JsonField, - private val gitId: JsonField, - private val dateConnected: JsonField, - private val dateUpdated: JsonField, - private val branch: JsonField, - private val name: JsonField, - private val private_: JsonField, - private val slug: JsonField, - private val url: JsonField, - private val rootDir: JsonField, - private val projectId: JsonField, - private val gitAccountId: JsonField, - private val additionalProperties: Map, - ) { - - private var validated: Boolean = false - - fun id(): String = id.getRequired("id") - - fun gitId(): Long = gitId.getRequired("gitId") - - fun dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") - - fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") - - fun branch(): Optional = Optional.ofNullable(branch.getNullable("branch")) - - fun name(): String = name.getRequired("name") - - fun private_(): Boolean = private_.getRequired("private") - - fun slug(): String = slug.getRequired("slug") - - fun url(): String = url.getRequired("url") - - fun rootDir(): Optional = Optional.ofNullable(rootDir.getNullable("rootDir")) - - fun projectId(): String = projectId.getRequired("projectId") - - fun gitAccountId(): String = gitAccountId.getRequired("gitAccountId") - - @JsonProperty("id") @ExcludeMissing fun _id() = id - - @JsonProperty("gitId") @ExcludeMissing fun _gitId() = gitId - - @JsonProperty("dateConnected") @ExcludeMissing fun _dateConnected() = dateConnected - - @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated - - @JsonProperty("branch") @ExcludeMissing fun _branch() = branch - - @JsonProperty("name") @ExcludeMissing fun _name() = name - - @JsonProperty("private") @ExcludeMissing fun _private_() = private_ - - @JsonProperty("slug") @ExcludeMissing fun _slug() = slug - - @JsonProperty("url") @ExcludeMissing fun _url() = url - - @JsonProperty("rootDir") @ExcludeMissing fun _rootDir() = rootDir - - @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId - - @JsonProperty("gitAccountId") @ExcludeMissing fun _gitAccountId() = gitAccountId - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): GitRepo = apply { - if (!validated) { - id() - gitId() - dateConnected() - dateUpdated() - branch() - name() - private_() - slug() - url() - rootDir() - projectId() - gitAccountId() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var id: JsonField = JsonMissing.of() - private var gitId: JsonField = JsonMissing.of() - private var dateConnected: JsonField = JsonMissing.of() - private var dateUpdated: JsonField = JsonMissing.of() - private var branch: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var private_: JsonField = JsonMissing.of() - private var slug: JsonField = JsonMissing.of() - private var url: JsonField = JsonMissing.of() - private var rootDir: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var gitAccountId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gitRepo: GitRepo) = apply { - this.id = gitRepo.id - this.gitId = gitRepo.gitId - this.dateConnected = gitRepo.dateConnected - this.dateUpdated = gitRepo.dateUpdated - this.branch = gitRepo.branch - this.name = gitRepo.name - this.private_ = gitRepo.private_ - this.slug = gitRepo.slug - this.url = gitRepo.url - this.rootDir = gitRepo.rootDir - this.projectId = gitRepo.projectId - this.gitAccountId = gitRepo.gitAccountId - additionalProperties(gitRepo.additionalProperties) - } - - fun id(id: String) = id(JsonField.of(id)) - - @JsonProperty("id") - @ExcludeMissing - fun id(id: JsonField) = apply { this.id = id } - - fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) - - @JsonProperty("gitId") - @ExcludeMissing - fun gitId(gitId: JsonField) = apply { this.gitId = gitId } - - fun dateConnected(dateConnected: OffsetDateTime) = - dateConnected(JsonField.of(dateConnected)) - - @JsonProperty("dateConnected") - @ExcludeMissing - fun dateConnected(dateConnected: JsonField) = apply { - this.dateConnected = dateConnected - } - - fun dateUpdated(dateUpdated: OffsetDateTime) = - dateUpdated(JsonField.of(dateUpdated)) - - @JsonProperty("dateUpdated") - @ExcludeMissing - fun dateUpdated(dateUpdated: JsonField) = apply { - this.dateUpdated = dateUpdated - } - - fun branch(branch: String) = branch(JsonField.of(branch)) - - @JsonProperty("branch") - @ExcludeMissing - fun branch(branch: JsonField) = apply { this.branch = branch } - - fun name(name: String) = name(JsonField.of(name)) - - @JsonProperty("name") - @ExcludeMissing - fun name(name: JsonField) = apply { this.name = name } - - fun private_(private_: Boolean) = private_(JsonField.of(private_)) - - @JsonProperty("private") - @ExcludeMissing - fun private_(private_: JsonField) = apply { this.private_ = private_ } - - fun slug(slug: String) = slug(JsonField.of(slug)) - - @JsonProperty("slug") - @ExcludeMissing - fun slug(slug: JsonField) = apply { this.slug = slug } - - fun url(url: String) = url(JsonField.of(url)) - - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) - - @JsonProperty("rootDir") - @ExcludeMissing - fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } - - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - @JsonProperty("projectId") - @ExcludeMissing - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) - - @JsonProperty("gitAccountId") - @ExcludeMissing - fun gitAccountId(gitAccountId: JsonField) = apply { - this.gitAccountId = gitAccountId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): GitRepo = - GitRepo( - id, - gitId, - dateConnected, - dateUpdated, - branch, - name, - private_, - slug, - url, - rootDir, - projectId, - gitAccountId, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is GitRepo && id == other.id && gitId == other.gitId && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && branch == other.branch && name == other.name && private_ == other.private_ && slug == other.slug && url == other.url && rootDir == other.rootDir && projectId == other.projectId && gitAccountId == other.gitAccountId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, gitId, dateConnected, dateUpdated, branch, name, private_, slug, url, rootDir, projectId, gitAccountId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GitRepo{id=$id, gitId=$gitId, dateConnected=$dateConnected, dateUpdated=$dateUpdated, branch=$branch, name=$name, private_=$private_, slug=$slug, url=$url, rootDir=$rootDir, projectId=$projectId, gitAccountId=$gitAccountId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Item && id == other.id && workspaceId == other.workspaceId && creatorId == other.creatorId && name == other.name && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && source == other.source && taskType == other.taskType && versionCount == other.versionCount && inferencePipelineCount == other.inferencePipelineCount && goalCount == other.goalCount && developmentGoalCount == other.developmentGoalCount && monitoringGoalCount == other.monitoringGoalCount && links == other.links && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, workspaceId, creatorId, name, dateCreated, dateUpdated, description, source, taskType, versionCount, inferencePipelineCount, goalCount, developmentGoalCount, monitoringGoalCount, links, gitRepo, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, links=$links, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProjectListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProjectListResponse{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateResponse.kt deleted file mode 100644 index bfbca982..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateResponse.kt +++ /dev/null @@ -1,139 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonField -import com.openlayer.api.core.JsonMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.toImmutable -import java.util.Objects - -@JsonDeserialize(builder = StoragePresignedUrlCreateResponse.Builder::class) -@NoAutoDetect -class StoragePresignedUrlCreateResponse -private constructor( - private val url: JsonField, - private val fields: JsonValue, - private val storageUri: JsonField, - private val additionalProperties: Map, -) { - - private var validated: Boolean = false - - /** The presigned url. */ - fun url(): String = url.getRequired("url") - - /** The storage URI to send back to the backend after the upload was completed. */ - fun storageUri(): String = storageUri.getRequired("storageUri") - - /** The presigned url. */ - @JsonProperty("url") @ExcludeMissing fun _url() = url - - /** Fields to include in the body of the upload. Only needed by s3 */ - @JsonProperty("fields") @ExcludeMissing fun _fields() = fields - - /** The storage URI to send back to the backend after the upload was completed. */ - @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate(): StoragePresignedUrlCreateResponse = apply { - if (!validated) { - url() - storageUri() - validated = true - } - } - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var url: JsonField = JsonMissing.of() - private var fields: JsonValue = JsonMissing.of() - private var storageUri: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(storagePresignedUrlCreateResponse: StoragePresignedUrlCreateResponse) = - apply { - this.url = storagePresignedUrlCreateResponse.url - this.fields = storagePresignedUrlCreateResponse.fields - this.storageUri = storagePresignedUrlCreateResponse.storageUri - additionalProperties(storagePresignedUrlCreateResponse.additionalProperties) - } - - /** The presigned url. */ - fun url(url: String) = url(JsonField.of(url)) - - /** The presigned url. */ - @JsonProperty("url") - @ExcludeMissing - fun url(url: JsonField) = apply { this.url = url } - - /** Fields to include in the body of the upload. Only needed by s3 */ - @JsonProperty("fields") - @ExcludeMissing - fun fields(fields: JsonValue) = apply { this.fields = fields } - - /** The storage URI to send back to the backend after the upload was completed. */ - fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) - - /** The storage URI to send back to the backend after the upload was completed. */ - @JsonProperty("storageUri") - @ExcludeMissing - fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): StoragePresignedUrlCreateResponse = - StoragePresignedUrlCreateResponse( - url, - fields, - storageUri, - additionalProperties.toImmutable(), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is StoragePresignedUrlCreateResponse && url == other.url && fields == other.fields && storageUri == other.storageUri && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(url, fields, storageUri, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StoragePresignedUrlCreateResponse{url=$url, fields=$fields, storageUri=$storageUri, additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveParams.kt similarity index 65% rename from openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitListParams.kt rename to openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveParams.kt index ac2859d3..258b399a 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitListParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveParams.kt @@ -1,82 +1,59 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.commits -import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import java.util.Objects -import java.util.Optional -class ProjectCommitListParams -constructor( - private val projectId: String, - private val page: Long?, - private val perPage: Long?, +/** Retrieve a project version (commit) by its id. */ +class CommitRetrieveParams +private constructor( + private val projectVersionId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { - fun projectId(): String = projectId - - fun page(): Optional = Optional.ofNullable(page) - - fun perPage(): Optional = Optional.ofNullable(perPage) + fun projectVersionId(): String = projectVersionId fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.page?.let { queryParams.put("page", listOf(it.toString())) } - this.perPage?.let { queryParams.put("perPage", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [CommitRetrieveParams]. + * + * The following fields are required: + * ```java + * .projectVersionId() + * ``` + */ @JvmStatic fun builder() = Builder() } - @NoAutoDetect - class Builder { + /** A builder for [CommitRetrieveParams]. */ + class Builder internal constructor() { - private var projectId: String? = null - private var page: Long? = null - private var perPage: Long? = null + private var projectVersionId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectCommitListParams: ProjectCommitListParams) = apply { - projectId = projectCommitListParams.projectId - page = projectCommitListParams.page - perPage = projectCommitListParams.perPage - additionalHeaders = projectCommitListParams.additionalHeaders.toBuilder() - additionalQueryParams = projectCommitListParams.additionalQueryParams.toBuilder() + internal fun from(commitRetrieveParams: CommitRetrieveParams) = apply { + projectVersionId = commitRetrieveParams.projectVersionId + additionalHeaders = commitRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = commitRetrieveParams.additionalQueryParams.toBuilder() } - fun projectId(projectId: String) = apply { this.projectId = projectId } - - /** The page to return in a paginated query. */ - fun page(page: Long) = apply { this.page = page } - - /** Maximum number of items to return per page. */ - fun perPage(perPage: Long) = apply { this.perPage = perPage } + fun projectVersionId(projectVersionId: String) = apply { + this.projectVersionId = projectVersionId + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -176,26 +153,46 @@ constructor( additionalQueryParams.removeAll(keys) } - fun build(): ProjectCommitListParams = - ProjectCommitListParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - page, - perPage, + /** + * Returns an immutable instance of [CommitRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectVersionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitRetrieveParams = + CommitRetrieveParams( + checkRequired("projectVersionId", projectVersionId), additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> projectVersionId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectCommitListParams && projectId == other.projectId && page == other.page && perPage == other.perPage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CommitRetrieveParams && projectVersionId == other.projectVersionId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, page, perPage, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectVersionId, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectCommitListParams{projectId=$projectId, page=$page, perPage=$perPage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CommitRetrieveParams{projectVersionId=$projectVersionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt new file mode 100644 index 00000000..952bdd3c --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt @@ -0,0 +1,1813 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CommitRetrieveResponse +private constructor( + private val id: JsonField, + private val commit: JsonField, + private val dateArchived: JsonField, + private val dateCreated: JsonField, + private val failingGoalCount: JsonField, + private val mlModelId: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val storageUri: JsonField, + private val totalGoalCount: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val archived: JsonField, + private val deploymentStatus: JsonField, + private val links: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), + @JsonProperty("dateArchived") + @ExcludeMissing + dateArchived: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") @ExcludeMissing mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("archived") @ExcludeMissing archived: JsonField = JsonMissing.of(), + @JsonProperty("deploymentStatus") + @ExcludeMissing + deploymentStatus: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + ) : this( + id, + commit, + dateArchived, + dateCreated, + failingGoalCount, + mlModelId, + passingGoalCount, + projectId, + status, + statusMessage, + storageUri, + totalGoalCount, + trainingDatasetId, + validationDatasetId, + archived, + deploymentStatus, + links, + mutableMapOf(), + ) + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The details of a commit (project version). + * + * @throws OpenlayerInvalidDataException 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 commit(): Commit = commit.getRequired("commit") + + /** + * The commit archive date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateArchived(): Optional = dateArchived.getOptional("dateArchived") + + /** + * The project version (commit) creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The number of tests that are failing for the commit. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The number of tests that are passing for the commit. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The commit status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The total number of tests for the commit. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * Whether the commit is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun archived(): Optional = archived.getOptional("archived") + + /** + * The deployment status associated with the commit's model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deploymentStatus(): Optional = deploymentStatus.getOptional("deploymentStatus") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun links(): Optional = links.getOptional("links") + + /** + * 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 [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun _dateArchived(): JsonField = dateArchived + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") @ExcludeMissing fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("archived") @ExcludeMissing fun _archived(): JsonField = archived + + /** + * Returns the raw JSON value of [deploymentStatus]. + * + * Unlike [deploymentStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deploymentStatus") + @ExcludeMissing + fun _deploymentStatus(): JsonField = deploymentStatus + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + @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 [CommitRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var commit: JsonField? = null + private var dateArchived: JsonField? = null + private var dateCreated: JsonField? = null + private var failingGoalCount: JsonField? = null + private var mlModelId: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var storageUri: JsonField? = null + private var totalGoalCount: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var archived: JsonField = JsonMissing.of() + private var deploymentStatus: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitRetrieveResponse: CommitRetrieveResponse) = apply { + id = commitRetrieveResponse.id + commit = commitRetrieveResponse.commit + dateArchived = commitRetrieveResponse.dateArchived + dateCreated = commitRetrieveResponse.dateCreated + failingGoalCount = commitRetrieveResponse.failingGoalCount + mlModelId = commitRetrieveResponse.mlModelId + passingGoalCount = commitRetrieveResponse.passingGoalCount + projectId = commitRetrieveResponse.projectId + status = commitRetrieveResponse.status + statusMessage = commitRetrieveResponse.statusMessage + storageUri = commitRetrieveResponse.storageUri + totalGoalCount = commitRetrieveResponse.totalGoalCount + trainingDatasetId = commitRetrieveResponse.trainingDatasetId + validationDatasetId = commitRetrieveResponse.validationDatasetId + archived = commitRetrieveResponse.archived + deploymentStatus = commitRetrieveResponse.deploymentStatus + links = commitRetrieveResponse.links + additionalProperties = commitRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The project version (commit) id. */ + 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 } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = commit(JsonField.of(commit)) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [Commit] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** The commit archive date. */ + fun dateArchived(dateArchived: OffsetDateTime?) = + dateArchived(JsonField.ofNullable(dateArchived)) + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The project version (commit) creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The commit status message. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The total number of tests for the commit. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean?) = archived(JsonField.ofNullable(archived)) + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = + deploymentStatus(JsonField.of(deploymentStatus)) + + /** + * Sets [Builder.deploymentStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentStatus] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deploymentStatus(deploymentStatus: JsonField) = apply { + this.deploymentStatus = deploymentStatus + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitRetrieveResponse = + CommitRetrieveResponse( + checkRequired("id", id), + checkRequired("commit", commit), + checkRequired("dateArchived", dateArchived), + checkRequired("dateCreated", dateCreated), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("mlModelId", mlModelId), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("storageUri", storageUri), + checkRequired("totalGoalCount", totalGoalCount), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + archived, + deploymentStatus, + links, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommitRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + commit().validate() + dateArchived() + dateCreated() + failingGoalCount() + mlModelId() + passingGoalCount() + projectId() + status().validate() + statusMessage() + storageUri() + totalGoalCount() + trainingDatasetId() + validationDatasetId() + archived() + deploymentStatus() + links().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + /** The details of a commit (project version). */ + class Commit + private constructor( + private val id: JsonField, + private val authorId: JsonField, + private val fileSize: JsonField, + private val message: JsonField, + private val mlModelId: JsonField, + private val storageUri: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val dateCreated: JsonField, + private val gitCommitRef: JsonField, + private val gitCommitSha: JsonField, + private val gitCommitUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("authorId") + @ExcludeMissing + authorId: JsonField = JsonMissing.of(), + @JsonProperty("fileSize") @ExcludeMissing fileSize: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") + @ExcludeMissing + mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitRef") + @ExcludeMissing + gitCommitRef: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitSha") + @ExcludeMissing + gitCommitSha: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitUrl") + @ExcludeMissing + gitCommitUrl: JsonField = JsonMissing.of(), + ) : this( + id, + authorId, + fileSize, + message, + mlModelId, + storageUri, + trainingDatasetId, + validationDatasetId, + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + mutableMapOf(), + ) + + /** + * The commit id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The author id of the commit. + * + * @throws OpenlayerInvalidDataException 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 authorId(): String = authorId.getRequired("authorId") + + /** + * The size of the commit bundle in bytes. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fileSize(): Optional = fileSize.getOptional("fileSize") + + /** + * The commit message. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = + trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * The commit creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateCreated(): Optional = dateCreated.getOptional("dateCreated") + + /** + * The ref of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitRef(): Optional = gitCommitRef.getOptional("gitCommitRef") + + /** + * The SHA of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitSha(): Optional = gitCommitSha.getOptional("gitCommitSha") + + /** + * The URL of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitUrl(): Optional = gitCommitUrl.getOptional("gitCommitUrl") + + /** + * 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 [authorId]. + * + * Unlike [authorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("authorId") @ExcludeMissing fun _authorId(): JsonField = authorId + + /** + * Returns the raw JSON value of [fileSize]. + * + * Unlike [fileSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileSize") @ExcludeMissing fun _fileSize(): JsonField = fileSize + + /** + * 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 [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") + @ExcludeMissing + fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [gitCommitRef]. + * + * Unlike [gitCommitRef], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitRef") + @ExcludeMissing + fun _gitCommitRef(): JsonField = gitCommitRef + + /** + * Returns the raw JSON value of [gitCommitSha]. + * + * Unlike [gitCommitSha], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitSha") + @ExcludeMissing + fun _gitCommitSha(): JsonField = gitCommitSha + + /** + * Returns the raw JSON value of [gitCommitUrl]. + * + * Unlike [gitCommitUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitUrl") + @ExcludeMissing + fun _gitCommitUrl(): JsonField = gitCommitUrl + + @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 [Commit]. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var authorId: JsonField? = null + private var fileSize: JsonField? = null + private var message: JsonField? = null + private var mlModelId: JsonField? = null + private var storageUri: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var dateCreated: JsonField = JsonMissing.of() + private var gitCommitRef: JsonField = JsonMissing.of() + private var gitCommitSha: JsonField = JsonMissing.of() + private var gitCommitUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + id = commit.id + authorId = commit.authorId + fileSize = commit.fileSize + message = commit.message + mlModelId = commit.mlModelId + storageUri = commit.storageUri + trainingDatasetId = commit.trainingDatasetId + validationDatasetId = commit.validationDatasetId + dateCreated = commit.dateCreated + gitCommitRef = commit.gitCommitRef + gitCommitSha = commit.gitCommitSha + gitCommitUrl = commit.gitCommitUrl + additionalProperties = commit.additionalProperties.toMutableMap() + } + + /** The commit id. */ + 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 } + + /** The author id of the commit. */ + fun authorId(authorId: String) = authorId(JsonField.of(authorId)) + + /** + * Sets [Builder.authorId] to an arbitrary JSON value. + * + * You should usually call [Builder.authorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorId(authorId: JsonField) = apply { this.authorId = authorId } + + /** The size of the commit bundle in bytes. */ + fun fileSize(fileSize: Long?) = fileSize(JsonField.ofNullable(fileSize)) + + /** + * Alias for [Builder.fileSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fileSize(fileSize: Long) = fileSize(fileSize as Long?) + + /** Alias for calling [Builder.fileSize] with `fileSize.orElse(null)`. */ + fun fileSize(fileSize: Optional) = fileSize(fileSize.getOrNull()) + + /** + * Sets [Builder.fileSize] to an arbitrary JSON value. + * + * You should usually call [Builder.fileSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } + + /** The commit message. */ + 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 } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** + * Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. + */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with + * `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The commit creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The ref of the corresponding git commit. */ + fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) + + /** + * Sets [Builder.gitCommitRef] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitRef] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitRef(gitCommitRef: JsonField) = apply { + this.gitCommitRef = gitCommitRef + } + + /** The SHA of the corresponding git commit. */ + fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) + + /** + * Sets [Builder.gitCommitSha] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitSha] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitSha(gitCommitSha: JsonField) = apply { + this.gitCommitSha = gitCommitSha + } + + /** The URL of the corresponding git commit. */ + fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) + + /** + * Sets [Builder.gitCommitUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitUrl(gitCommitUrl: JsonField) = apply { + this.gitCommitUrl = gitCommitUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Commit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Commit = + Commit( + checkRequired("id", id), + checkRequired("authorId", authorId), + checkRequired("fileSize", fileSize), + checkRequired("message", message), + checkRequired("mlModelId", mlModelId), + checkRequired("storageUri", storageUri), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Commit = apply { + if (validated) { + return@apply + } + + id() + authorId() + fileSize() + message() + mlModelId() + storageUri() + trainingDatasetId() + validationDatasetId() + dateCreated() + gitCommitRef() + gitCommitSha() + gitCommitUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && storageUri == other.storageUri && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && dateCreated == other.dateCreated && gitCommitRef == other.gitCommitRef && gitCommitSha == other.gitCommitSha && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, authorId, fileSize, message, mlModelId, storageUri, trainingDatasetId, validationDatasetId, dateCreated, gitCommitRef, gitCommitSha, gitCommitUrl, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Commit{id=$id, authorId=$authorId, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, storageUri=$storageUri, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, dateCreated=$dateCreated, gitCommitRef=$gitCommitRef, gitCommitSha=$gitCommitSha, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CommitRetrieveResponse && id == other.id && commit == other.commit && dateArchived == other.dateArchived && dateCreated == other.dateCreated && failingGoalCount == other.failingGoalCount && mlModelId == other.mlModelId && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && storageUri == other.storageUri && totalGoalCount == other.totalGoalCount && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && archived == other.archived && deploymentStatus == other.deploymentStatus && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, commit, dateArchived, dateCreated, failingGoalCount, mlModelId, passingGoalCount, projectId, status, statusMessage, storageUri, totalGoalCount, trainingDatasetId, validationDatasetId, archived, deploymentStatus, links, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitRetrieveResponse{id=$id, commit=$commit, dateArchived=$dateArchived, dateCreated=$dateCreated, failingGoalCount=$failingGoalCount, mlModelId=$mlModelId, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, storageUri=$storageUri, totalGoalCount=$totalGoalCount, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, archived=$archived, deploymentStatus=$deploymentStatus, links=$links, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt new file mode 100644 index 00000000..e46cfa17 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt @@ -0,0 +1,613 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits.testresults + +import com.fasterxml.jackson.annotation.JsonCreator +import com.openlayer.api.core.Enum +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List the test results for a project commit (project version). */ +class TestResultListParams +private constructor( + private val projectVersionId: String, + private val includeArchived: Boolean?, + private val page: Long?, + private val perPage: Long?, + private val status: Status?, + private val type: Type?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun projectVersionId(): String = projectVersionId + + /** Include archived goals. */ + fun includeArchived(): Optional = Optional.ofNullable(includeArchived) + + /** The page to return in a paginated query. */ + fun page(): Optional = Optional.ofNullable(page) + + /** Maximum number of items to return per page. */ + fun perPage(): Optional = Optional.ofNullable(perPage) + + /** + * Filter list of test results by status. Available statuses are `running`, `passing`, + * `failing`, `skipped`, and `error`. + */ + fun status(): Optional = Optional.ofNullable(status) + + /** + * Filter objects by test type. Available types are `integrity`, `consistency`, `performance`, + * `fairness`, and `robustness`. + */ + fun type(): Optional = Optional.ofNullable(type) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TestResultListParams]. + * + * The following fields are required: + * ```java + * .projectVersionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TestResultListParams]. */ + class Builder internal constructor() { + + private var projectVersionId: String? = null + private var includeArchived: Boolean? = null + private var page: Long? = null + private var perPage: Long? = null + private var status: Status? = null + private var type: Type? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(testResultListParams: TestResultListParams) = apply { + projectVersionId = testResultListParams.projectVersionId + includeArchived = testResultListParams.includeArchived + page = testResultListParams.page + perPage = testResultListParams.perPage + status = testResultListParams.status + type = testResultListParams.type + additionalHeaders = testResultListParams.additionalHeaders.toBuilder() + additionalQueryParams = testResultListParams.additionalQueryParams.toBuilder() + } + + fun projectVersionId(projectVersionId: String) = apply { + this.projectVersionId = projectVersionId + } + + /** Include archived goals. */ + fun includeArchived(includeArchived: Boolean?) = apply { + this.includeArchived = includeArchived + } + + /** + * Alias for [Builder.includeArchived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeArchived(includeArchived: Boolean) = includeArchived(includeArchived as Boolean?) + + /** Alias for calling [Builder.includeArchived] with `includeArchived.orElse(null)`. */ + fun includeArchived(includeArchived: Optional) = + includeArchived(includeArchived.getOrNull()) + + /** The page to return in a paginated query. */ + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.getOrNull()) + + /** + * Filter list of test results by status. Available statuses are `running`, `passing`, + * `failing`, `skipped`, and `error`. + */ + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Filter objects by test type. Available types are `integrity`, `consistency`, + * `performance`, `fairness`, and `robustness`. + */ + fun type(type: Type?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.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 [TestResultListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectVersionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TestResultListParams = + TestResultListParams( + checkRequired("projectVersionId", projectVersionId), + includeArchived, + page, + perPage, + status, + type, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> projectVersionId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeArchived?.let { put("includeArchived", it.toString()) } + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + status?.let { put("status", it.toString()) } + type?.let { put("type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** + * Filter list of test results by status. Available statuses are `running`, `passing`, + * `failing`, `skipped`, and `error`. + */ + class Status @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 RUNNING = of("running") + + @JvmField val PASSING = of("passing") + + @JvmField val FAILING = of("failing") + + @JvmField val SKIPPED = of("skipped") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + /** An enum member indicating that [Status] 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) { + RUNNING -> Value.RUNNING + PASSING -> Value.PASSING + FAILING -> Value.FAILING + SKIPPED -> Value.SKIPPED + ERROR -> Value.ERROR + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUNNING -> Known.RUNNING + PASSING -> Known.PASSING + FAILING -> Known.FAILING + SKIPPED -> Known.SKIPPED + ERROR -> Known.ERROR + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Filter objects by test type. Available types are `integrity`, `consistency`, `performance`, + * `fairness`, and `robustness`. + */ + class Type @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 INTEGRITY = of("integrity") + + @JvmField val CONSISTENCY = of("consistency") + + @JvmField val PERFORMANCE = of("performance") + + @JvmField val FAIRNESS = of("fairness") + + @JvmField val ROBUSTNESS = of("robustness") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INTEGRITY, + CONSISTENCY, + PERFORMANCE, + FAIRNESS, + ROBUSTNESS, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + INTEGRITY, + CONSISTENCY, + PERFORMANCE, + FAIRNESS, + ROBUSTNESS, + /** An enum member indicating that [Type] 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) { + INTEGRITY -> Value.INTEGRITY + CONSISTENCY -> Value.CONSISTENCY + PERFORMANCE -> Value.PERFORMANCE + FAIRNESS -> Value.FAIRNESS + ROBUSTNESS -> Value.ROBUSTNESS + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INTEGRITY -> Known.INTEGRITY + CONSISTENCY -> Known.CONSISTENCY + PERFORMANCE -> Known.PERFORMANCE + FAIRNESS -> Known.FAIRNESS + ROBUSTNESS -> Known.ROBUSTNESS + else -> throw OpenlayerInvalidDataException("Unknown Type: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TestResultListParams && projectVersionId == other.projectVersionId && includeArchived == other.includeArchived && page == other.page && perPage == other.perPage && status == other.status && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectVersionId, includeArchived, page, perPage, status, type, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TestResultListParams{projectVersionId=$projectVersionId, includeArchived=$includeArchived, page=$page, perPage=$perPage, status=$status, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt new file mode 100644 index 00000000..fb24b414 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt @@ -0,0 +1,2605 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits.testresults + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.BaseDeserializer +import com.openlayer.api.core.BaseSerializer +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.allMaxBy +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.getOrThrow +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TestResultListResponse +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 [TestResultListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TestResultListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(testResultListResponse: TestResultListResponse) = apply { + items = testResultListResponse.items.map { it.toMutableList() } + additionalProperties = testResultListResponse.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 [TestResultListResponse]. + * + * 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(): TestResultListResponse = + TestResultListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TestResultListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + class Item + private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateDataEnds: JsonField, + private val dateDataStarts: JsonField, + private val dateUpdated: JsonField, + private val inferencePipelineId: JsonField, + private val projectVersionId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val goal: JsonField, + private val goalId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateDataEnds") + @ExcludeMissing + dateDataEnds: JsonField = JsonMissing.of(), + @JsonProperty("dateDataStarts") + @ExcludeMissing + dateDataStarts: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineId") + @ExcludeMissing + inferencePipelineId: JsonField = JsonMissing.of(), + @JsonProperty("projectVersionId") + @ExcludeMissing + projectVersionId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("goal") @ExcludeMissing goal: JsonField = JsonMissing.of(), + @JsonProperty("goalId") @ExcludeMissing goalId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateDataEnds, + dateDataStarts, + dateUpdated, + inferencePipelineId, + projectVersionId, + status, + statusMessage, + goal, + goalId, + mutableMapOf(), + ) + + /** + * Project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The data end date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateDataEnds(): Optional = dateDataEnds.getOptional("dateDataEnds") + + /** + * The data start date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateDataStarts(): Optional = + dateDataStarts.getOptional("dateDataStarts") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inferencePipelineId(): Optional = + inferencePipelineId.getOptional("inferencePipelineId") + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun projectVersionId(): Optional = projectVersionId.getOptional("projectVersionId") + + /** + * The status of the test. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun goal(): Optional = goal.getOptional("goal") + + /** + * The test id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun goalId(): Optional = goalId.getOptional("goalId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateDataEnds]. + * + * Unlike [dateDataEnds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateDataEnds") + @ExcludeMissing + fun _dateDataEnds(): JsonField = dateDataEnds + + /** + * Returns the raw JSON value of [dateDataStarts]. + * + * Unlike [dateDataStarts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateDataStarts") + @ExcludeMissing + fun _dateDataStarts(): JsonField = dateDataStarts + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inferencePipelineId]. + * + * Unlike [inferencePipelineId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineId") + @ExcludeMissing + fun _inferencePipelineId(): JsonField = inferencePipelineId + + /** + * Returns the raw JSON value of [projectVersionId]. + * + * Unlike [projectVersionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectVersionId") + @ExcludeMissing + fun _projectVersionId(): JsonField = projectVersionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [goal]. + * + * Unlike [goal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goal") @ExcludeMissing fun _goal(): JsonField = goal + + /** + * Returns the raw JSON value of [goalId]. + * + * Unlike [goalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalId") @ExcludeMissing fun _goalId(): JsonField = goalId + + @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() + * .dateCreated() + * .dateDataEnds() + * .dateDataStarts() + * .dateUpdated() + * .inferencePipelineId() + * .projectVersionId() + * .status() + * .statusMessage() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateDataEnds: JsonField? = null + private var dateDataStarts: JsonField? = null + private var dateUpdated: JsonField? = null + private var inferencePipelineId: JsonField? = null + private var projectVersionId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var goal: JsonField = JsonMissing.of() + private var goalId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + dateCreated = item.dateCreated + dateDataEnds = item.dateDataEnds + dateDataStarts = item.dateDataStarts + dateUpdated = item.dateUpdated + inferencePipelineId = item.inferencePipelineId + projectVersionId = item.projectVersionId + status = item.status + statusMessage = item.statusMessage + goal = item.goal + goalId = item.goalId + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** Project version (commit) id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The data end date. */ + fun dateDataEnds(dateDataEnds: OffsetDateTime?) = + dateDataEnds(JsonField.ofNullable(dateDataEnds)) + + /** Alias for calling [Builder.dateDataEnds] with `dateDataEnds.orElse(null)`. */ + fun dateDataEnds(dateDataEnds: Optional) = + dateDataEnds(dateDataEnds.getOrNull()) + + /** + * Sets [Builder.dateDataEnds] to an arbitrary JSON value. + * + * You should usually call [Builder.dateDataEnds] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateDataEnds(dateDataEnds: JsonField) = apply { + this.dateDataEnds = dateDataEnds + } + + /** The data start date. */ + fun dateDataStarts(dateDataStarts: OffsetDateTime?) = + dateDataStarts(JsonField.ofNullable(dateDataStarts)) + + /** Alias for calling [Builder.dateDataStarts] with `dateDataStarts.orElse(null)`. */ + fun dateDataStarts(dateDataStarts: Optional) = + dateDataStarts(dateDataStarts.getOrNull()) + + /** + * Sets [Builder.dateDataStarts] to an arbitrary JSON value. + * + * You should usually call [Builder.dateDataStarts] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateDataStarts(dateDataStarts: JsonField) = apply { + this.dateDataStarts = dateDataStarts + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline id. */ + fun inferencePipelineId(inferencePipelineId: String?) = + inferencePipelineId(JsonField.ofNullable(inferencePipelineId)) + + /** + * Alias for calling [Builder.inferencePipelineId] with + * `inferencePipelineId.orElse(null)`. + */ + fun inferencePipelineId(inferencePipelineId: Optional) = + inferencePipelineId(inferencePipelineId.getOrNull()) + + /** + * Sets [Builder.inferencePipelineId] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineId(inferencePipelineId: JsonField) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** The project version (commit) id. */ + fun projectVersionId(projectVersionId: String?) = + projectVersionId(JsonField.ofNullable(projectVersionId)) + + /** + * Alias for calling [Builder.projectVersionId] with `projectVersionId.orElse(null)`. + */ + fun projectVersionId(projectVersionId: Optional) = + projectVersionId(projectVersionId.getOrNull()) + + /** + * Sets [Builder.projectVersionId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectVersionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectVersionId(projectVersionId: JsonField) = apply { + this.projectVersionId = projectVersionId + } + + /** The status of the test. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + fun goal(goal: Goal) = goal(JsonField.of(goal)) + + /** + * Sets [Builder.goal] to an arbitrary JSON value. + * + * You should usually call [Builder.goal] with a well-typed [Goal] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun goal(goal: JsonField) = apply { this.goal = goal } + + /** The test id. */ + fun goalId(goalId: String?) = goalId(JsonField.ofNullable(goalId)) + + /** Alias for calling [Builder.goalId] with `goalId.orElse(null)`. */ + fun goalId(goalId: Optional) = goalId(goalId.getOrNull()) + + /** + * Sets [Builder.goalId] to an arbitrary JSON value. + * + * You should usually call [Builder.goalId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalId(goalId: JsonField) = apply { this.goalId = goalId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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() + * .dateCreated() + * .dateDataEnds() + * .dateDataStarts() + * .dateUpdated() + * .inferencePipelineId() + * .projectVersionId() + * .status() + * .statusMessage() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateDataEnds", dateDataEnds), + checkRequired("dateDataStarts", dateDataStarts), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inferencePipelineId", inferencePipelineId), + checkRequired("projectVersionId", projectVersionId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + goal, + goalId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateDataEnds() + dateDataStarts() + dateUpdated() + inferencePipelineId() + projectVersionId() + status().validate() + statusMessage() + goal().ifPresent { it.validate() } + goalId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateDataEnds.asKnown().isPresent) 1 else 0) + + (if (dateDataStarts.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineId.asKnown().isPresent) 1 else 0) + + (if (projectVersionId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (goal.asKnown().getOrNull()?.validity() ?: 0) + + (if (goalId.asKnown().isPresent) 1 else 0) + + /** The status of the test. */ + class Status @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 RUNNING = of("running") + + @JvmField val PASSING = of("passing") + + @JvmField val FAILING = of("failing") + + @JvmField val SKIPPED = of("skipped") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + /** + * An enum member indicating that [Status] 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) { + RUNNING -> Value.RUNNING + PASSING -> Value.PASSING + FAILING -> Value.FAILING + SKIPPED -> Value.SKIPPED + ERROR -> Value.ERROR + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUNNING -> Known.RUNNING + PASSING -> Known.PASSING + FAILING -> Known.FAILING + SKIPPED -> Known.SKIPPED + ERROR -> Known.ERROR + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Goal + private constructor( + private val id: JsonField, + private val commentCount: JsonField, + private val creatorId: JsonField, + private val dateArchived: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val description: JsonValue, + private val name: JsonField, + private val number: JsonField, + private val originProjectVersionId: JsonField, + private val subtype: JsonField, + private val suggested: JsonField, + private val thresholds: JsonField>, + private val type: JsonField, + private val archived: JsonField, + private val delayWindow: JsonField, + private val evaluationWindow: JsonField, + private val usesMlModel: JsonField, + private val usesProductionData: JsonField, + private val usesReferenceDataset: JsonField, + private val usesTrainingDataset: JsonField, + private val usesValidationDataset: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("commentCount") + @ExcludeMissing + commentCount: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateArchived") + @ExcludeMissing + dateArchived: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("number") @ExcludeMissing number: JsonField = JsonMissing.of(), + @JsonProperty("originProjectVersionId") + @ExcludeMissing + originProjectVersionId: JsonField = JsonMissing.of(), + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("suggested") + @ExcludeMissing + suggested: JsonField = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + thresholds: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("archived") + @ExcludeMissing + archived: JsonField = JsonMissing.of(), + @JsonProperty("delayWindow") + @ExcludeMissing + delayWindow: JsonField = JsonMissing.of(), + @JsonProperty("evaluationWindow") + @ExcludeMissing + evaluationWindow: JsonField = JsonMissing.of(), + @JsonProperty("usesMlModel") + @ExcludeMissing + usesMlModel: JsonField = JsonMissing.of(), + @JsonProperty("usesProductionData") + @ExcludeMissing + usesProductionData: JsonField = JsonMissing.of(), + @JsonProperty("usesReferenceDataset") + @ExcludeMissing + usesReferenceDataset: JsonField = JsonMissing.of(), + @JsonProperty("usesTrainingDataset") + @ExcludeMissing + usesTrainingDataset: JsonField = JsonMissing.of(), + @JsonProperty("usesValidationDataset") + @ExcludeMissing + usesValidationDataset: JsonField = JsonMissing.of(), + ) : this( + id, + commentCount, + creatorId, + dateArchived, + dateCreated, + dateUpdated, + description, + name, + number, + originProjectVersionId, + subtype, + suggested, + thresholds, + type, + archived, + delayWindow, + evaluationWindow, + usesMlModel, + usesProductionData, + usesReferenceDataset, + usesTrainingDataset, + usesValidationDataset, + mutableMapOf(), + ) + + /** + * The test id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of comments on the test. + * + * @throws OpenlayerInvalidDataException 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 commentCount(): Long = commentCount.getRequired("commentCount") + + /** + * The test creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The date the test was archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dateArchived(): Optional = dateArchived.getOptional("dateArchived") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** The test description. */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonValue = description + + /** + * The test name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The test number. + * + * @throws OpenlayerInvalidDataException 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 number(): Long = number.getRequired("number") + + /** + * The project version (commit) id where the test was created. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun originProjectVersionId(): Optional = + originProjectVersionId.getOptional("originProjectVersionId") + + /** + * The test subtype. + * + * @throws OpenlayerInvalidDataException 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 subtype(): String = subtype.getRequired("subtype") + + /** + * Whether the test is suggested or user-created. + * + * @throws OpenlayerInvalidDataException 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 suggested(): Boolean = suggested.getRequired("suggested") + + /** + * @throws OpenlayerInvalidDataException 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 thresholds(): List = thresholds.getRequired("thresholds") + + /** + * The test type. + * + * @throws OpenlayerInvalidDataException 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 type(): String = type.getRequired("type") + + /** + * Whether the test is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun archived(): Optional = archived.getOptional("archived") + + /** + * The delay window in seconds. Only applies to tests that use production data. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun delayWindow(): Optional = delayWindow.getOptional("delayWindow") + + /** + * The evaluation window in seconds. Only applies to tests that use production data. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluationWindow(): Optional = + evaluationWindow.getOptional("evaluationWindow") + + /** + * Whether the test uses an ML model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesMlModel(): Optional = usesMlModel.getOptional("usesMlModel") + + /** + * Whether the test uses production data (monitoring mode only). + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesProductionData(): Optional = + usesProductionData.getOptional("usesProductionData") + + /** + * Whether the test uses a reference dataset (monitoring mode only). + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesReferenceDataset(): Optional = + usesReferenceDataset.getOptional("usesReferenceDataset") + + /** + * Whether the test uses a training dataset. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesTrainingDataset(): Optional = + usesTrainingDataset.getOptional("usesTrainingDataset") + + /** + * Whether the test uses a validation dataset. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesValidationDataset(): Optional = + usesValidationDataset.getOptional("usesValidationDataset") + + /** + * 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 [commentCount]. + * + * Unlike [commentCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("commentCount") + @ExcludeMissing + fun _commentCount(): JsonField = commentCount + + /** + * Returns the raw JSON value of [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("creatorId") + @ExcludeMissing + fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun _dateArchived(): JsonField = dateArchived + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * 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 [number]. + * + * Unlike [number], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("number") @ExcludeMissing fun _number(): JsonField = number + + /** + * Returns the raw JSON value of [originProjectVersionId]. + * + * Unlike [originProjectVersionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("originProjectVersionId") + @ExcludeMissing + fun _originProjectVersionId(): JsonField = originProjectVersionId + + /** + * Returns the raw JSON value of [subtype]. + * + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype + + /** + * Returns the raw JSON value of [suggested]. + * + * Unlike [suggested], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("suggested") + @ExcludeMissing + fun _suggested(): JsonField = suggested + + /** + * Returns the raw JSON value of [thresholds]. + * + * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("archived") @ExcludeMissing fun _archived(): JsonField = archived + + /** + * Returns the raw JSON value of [delayWindow]. + * + * Unlike [delayWindow], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("delayWindow") + @ExcludeMissing + fun _delayWindow(): JsonField = delayWindow + + /** + * Returns the raw JSON value of [evaluationWindow]. + * + * Unlike [evaluationWindow], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("evaluationWindow") + @ExcludeMissing + fun _evaluationWindow(): JsonField = evaluationWindow + + /** + * Returns the raw JSON value of [usesMlModel]. + * + * Unlike [usesMlModel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("usesMlModel") + @ExcludeMissing + fun _usesMlModel(): JsonField = usesMlModel + + /** + * Returns the raw JSON value of [usesProductionData]. + * + * Unlike [usesProductionData], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesProductionData") + @ExcludeMissing + fun _usesProductionData(): JsonField = usesProductionData + + /** + * Returns the raw JSON value of [usesReferenceDataset]. + * + * Unlike [usesReferenceDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesReferenceDataset") + @ExcludeMissing + fun _usesReferenceDataset(): JsonField = usesReferenceDataset + + /** + * Returns the raw JSON value of [usesTrainingDataset]. + * + * Unlike [usesTrainingDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesTrainingDataset") + @ExcludeMissing + fun _usesTrainingDataset(): JsonField = usesTrainingDataset + + /** + * Returns the raw JSON value of [usesValidationDataset]. + * + * Unlike [usesValidationDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesValidationDataset") + @ExcludeMissing + fun _usesValidationDataset(): JsonField = usesValidationDataset + + @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 [Goal]. + * + * The following fields are required: + * ```java + * .id() + * .commentCount() + * .creatorId() + * .dateArchived() + * .dateCreated() + * .dateUpdated() + * .description() + * .name() + * .number() + * .originProjectVersionId() + * .subtype() + * .suggested() + * .thresholds() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Goal]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var commentCount: JsonField? = null + private var creatorId: JsonField? = null + private var dateArchived: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonValue? = null + private var name: JsonField? = null + private var number: JsonField? = null + private var originProjectVersionId: JsonField? = null + private var subtype: JsonField? = null + private var suggested: JsonField? = null + private var thresholds: JsonField>? = null + private var type: JsonField? = null + private var archived: JsonField = JsonMissing.of() + private var delayWindow: JsonField = JsonMissing.of() + private var evaluationWindow: JsonField = JsonMissing.of() + private var usesMlModel: JsonField = JsonMissing.of() + private var usesProductionData: JsonField = JsonMissing.of() + private var usesReferenceDataset: JsonField = JsonMissing.of() + private var usesTrainingDataset: JsonField = JsonMissing.of() + private var usesValidationDataset: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(goal: Goal) = apply { + id = goal.id + commentCount = goal.commentCount + creatorId = goal.creatorId + dateArchived = goal.dateArchived + dateCreated = goal.dateCreated + dateUpdated = goal.dateUpdated + description = goal.description + name = goal.name + number = goal.number + originProjectVersionId = goal.originProjectVersionId + subtype = goal.subtype + suggested = goal.suggested + thresholds = goal.thresholds.map { it.toMutableList() } + type = goal.type + archived = goal.archived + delayWindow = goal.delayWindow + evaluationWindow = goal.evaluationWindow + usesMlModel = goal.usesMlModel + usesProductionData = goal.usesProductionData + usesReferenceDataset = goal.usesReferenceDataset + usesTrainingDataset = goal.usesTrainingDataset + usesValidationDataset = goal.usesValidationDataset + additionalProperties = goal.additionalProperties.toMutableMap() + } + + /** The test id. */ + 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 } + + /** The number of comments on the test. */ + fun commentCount(commentCount: Long) = commentCount(JsonField.of(commentCount)) + + /** + * Sets [Builder.commentCount] to an arbitrary JSON value. + * + * You should usually call [Builder.commentCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun commentCount(commentCount: JsonField) = apply { + this.commentCount = commentCount + } + + /** The test creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The date the test was archived. */ + fun dateArchived(dateArchived: OffsetDateTime?) = + dateArchived(JsonField.ofNullable(dateArchived)) + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The test description. */ + fun description(description: JsonValue) = apply { this.description = description } + + /** The test name. */ + 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 } + + /** The test number. */ + fun number(number: Long) = number(JsonField.of(number)) + + /** + * Sets [Builder.number] to an arbitrary JSON value. + * + * You should usually call [Builder.number] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun number(number: JsonField) = apply { this.number = number } + + /** The project version (commit) id where the test was created. */ + fun originProjectVersionId(originProjectVersionId: String?) = + originProjectVersionId(JsonField.ofNullable(originProjectVersionId)) + + /** + * Alias for calling [Builder.originProjectVersionId] with + * `originProjectVersionId.orElse(null)`. + */ + fun originProjectVersionId(originProjectVersionId: Optional) = + originProjectVersionId(originProjectVersionId.getOrNull()) + + /** + * Sets [Builder.originProjectVersionId] to an arbitrary JSON value. + * + * You should usually call [Builder.originProjectVersionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun originProjectVersionId(originProjectVersionId: JsonField) = apply { + this.originProjectVersionId = originProjectVersionId + } + + /** The test subtype. */ + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) + + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + + /** Whether the test is suggested or user-created. */ + fun suggested(suggested: Boolean) = suggested(JsonField.of(suggested)) + + /** + * Sets [Builder.suggested] to an arbitrary JSON value. + * + * You should usually call [Builder.suggested] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun suggested(suggested: JsonField) = apply { this.suggested = suggested } + + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + + /** + * Sets [Builder.thresholds] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** + * Adds a single [Threshold] to [thresholds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThreshold(threshold: Threshold) = apply { + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) + } + } + + /** The test type. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Whether the test is archived. */ + fun archived(archived: Boolean) = archived(JsonField.of(archived)) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The delay window in seconds. Only applies to tests that use production data. */ + fun delayWindow(delayWindow: Double?) = + delayWindow(JsonField.ofNullable(delayWindow)) + + /** + * Alias for [Builder.delayWindow]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun delayWindow(delayWindow: Double) = delayWindow(delayWindow as Double?) + + /** Alias for calling [Builder.delayWindow] with `delayWindow.orElse(null)`. */ + fun delayWindow(delayWindow: Optional) = + delayWindow(delayWindow.getOrNull()) + + /** + * Sets [Builder.delayWindow] to an arbitrary JSON value. + * + * You should usually call [Builder.delayWindow] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun delayWindow(delayWindow: JsonField) = apply { + this.delayWindow = delayWindow + } + + /** + * The evaluation window in seconds. Only applies to tests that use production data. + */ + fun evaluationWindow(evaluationWindow: Double?) = + evaluationWindow(JsonField.ofNullable(evaluationWindow)) + + /** + * Alias for [Builder.evaluationWindow]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun evaluationWindow(evaluationWindow: Double) = + evaluationWindow(evaluationWindow as Double?) + + /** + * Alias for calling [Builder.evaluationWindow] with + * `evaluationWindow.orElse(null)`. + */ + fun evaluationWindow(evaluationWindow: Optional) = + evaluationWindow(evaluationWindow.getOrNull()) + + /** + * Sets [Builder.evaluationWindow] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluationWindow] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun evaluationWindow(evaluationWindow: JsonField) = apply { + this.evaluationWindow = evaluationWindow + } + + /** Whether the test uses an ML model. */ + fun usesMlModel(usesMlModel: Boolean) = usesMlModel(JsonField.of(usesMlModel)) + + /** + * Sets [Builder.usesMlModel] to an arbitrary JSON value. + * + * You should usually call [Builder.usesMlModel] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun usesMlModel(usesMlModel: JsonField) = apply { + this.usesMlModel = usesMlModel + } + + /** Whether the test uses production data (monitoring mode only). */ + fun usesProductionData(usesProductionData: Boolean) = + usesProductionData(JsonField.of(usesProductionData)) + + /** + * Sets [Builder.usesProductionData] to an arbitrary JSON value. + * + * You should usually call [Builder.usesProductionData] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun usesProductionData(usesProductionData: JsonField) = apply { + this.usesProductionData = usesProductionData + } + + /** Whether the test uses a reference dataset (monitoring mode only). */ + fun usesReferenceDataset(usesReferenceDataset: Boolean) = + usesReferenceDataset(JsonField.of(usesReferenceDataset)) + + /** + * Sets [Builder.usesReferenceDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.usesReferenceDataset] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usesReferenceDataset(usesReferenceDataset: JsonField) = apply { + this.usesReferenceDataset = usesReferenceDataset + } + + /** Whether the test uses a training dataset. */ + fun usesTrainingDataset(usesTrainingDataset: Boolean) = + usesTrainingDataset(JsonField.of(usesTrainingDataset)) + + /** + * Sets [Builder.usesTrainingDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.usesTrainingDataset] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun usesTrainingDataset(usesTrainingDataset: JsonField) = apply { + this.usesTrainingDataset = usesTrainingDataset + } + + /** Whether the test uses a validation dataset. */ + fun usesValidationDataset(usesValidationDataset: Boolean) = + usesValidationDataset(JsonField.of(usesValidationDataset)) + + /** + * Sets [Builder.usesValidationDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.usesValidationDataset] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usesValidationDataset(usesValidationDataset: JsonField) = apply { + this.usesValidationDataset = usesValidationDataset + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Goal]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commentCount() + * .creatorId() + * .dateArchived() + * .dateCreated() + * .dateUpdated() + * .description() + * .name() + * .number() + * .originProjectVersionId() + * .subtype() + * .suggested() + * .thresholds() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Goal = + Goal( + checkRequired("id", id), + checkRequired("commentCount", commentCount), + checkRequired("creatorId", creatorId), + checkRequired("dateArchived", dateArchived), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("name", name), + checkRequired("number", number), + checkRequired("originProjectVersionId", originProjectVersionId), + checkRequired("subtype", subtype), + checkRequired("suggested", suggested), + checkRequired("thresholds", thresholds).map { it.toImmutable() }, + checkRequired("type", type), + archived, + delayWindow, + evaluationWindow, + usesMlModel, + usesProductionData, + usesReferenceDataset, + usesTrainingDataset, + usesValidationDataset, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Goal = apply { + if (validated) { + return@apply + } + + id() + commentCount() + creatorId() + dateArchived() + dateCreated() + dateUpdated() + name() + number() + originProjectVersionId() + subtype() + suggested() + thresholds().forEach { it.validate() } + type() + archived() + delayWindow() + evaluationWindow() + usesMlModel() + usesProductionData() + usesReferenceDataset() + usesTrainingDataset() + usesValidationDataset() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (commentCount.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (number.asKnown().isPresent) 1 else 0) + + (if (originProjectVersionId.asKnown().isPresent) 1 else 0) + + (if (subtype.asKnown().isPresent) 1 else 0) + + (if (suggested.asKnown().isPresent) 1 else 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (delayWindow.asKnown().isPresent) 1 else 0) + + (if (evaluationWindow.asKnown().isPresent) 1 else 0) + + (if (usesMlModel.asKnown().isPresent) 1 else 0) + + (if (usesProductionData.asKnown().isPresent) 1 else 0) + + (if (usesReferenceDataset.asKnown().isPresent) 1 else 0) + + (if (usesTrainingDataset.asKnown().isPresent) 1 else 0) + + (if (usesValidationDataset.asKnown().isPresent) 1 else 0) + + class Threshold + private constructor( + private val insightName: JsonField, + private val insightParameters: JsonField>, + private val measurement: JsonField, + private val operator: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("insightName") + @ExcludeMissing + insightName: JsonField = JsonMissing.of(), + @JsonProperty("insightParameters") + @ExcludeMissing + insightParameters: JsonField> = JsonMissing.of(), + @JsonProperty("measurement") + @ExcludeMissing + measurement: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this( + insightName, + insightParameters, + measurement, + operator, + value, + mutableMapOf(), + ) + + /** + * The insight name to be evaluated. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun insightName(): Optional = insightName.getOptional("insightName") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun insightParameters(): Optional> = + insightParameters.getOptional("insightParameters") + + /** + * The measurement to be evaluated. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun measurement(): Optional = measurement.getOptional("measurement") + + /** + * The operator to be used for the evaluation. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun operator(): Optional = operator.getOptional("operator") + + /** + * The value to be compared. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [insightName]. + * + * Unlike [insightName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("insightName") + @ExcludeMissing + fun _insightName(): JsonField = insightName + + /** + * Returns the raw JSON value of [insightParameters]. + * + * Unlike [insightParameters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("insightParameters") + @ExcludeMissing + fun _insightParameters(): JsonField> = insightParameters + + /** + * Returns the raw JSON value of [measurement]. + * + * Unlike [measurement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("measurement") + @ExcludeMissing + fun _measurement(): JsonField = measurement + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [Threshold]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Threshold]. */ + class Builder internal constructor() { + + private var insightName: JsonField = JsonMissing.of() + private var insightParameters: JsonField>? = null + private var measurement: JsonField = JsonMissing.of() + private var operator: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(threshold: Threshold) = apply { + insightName = threshold.insightName + insightParameters = threshold.insightParameters.map { it.toMutableList() } + measurement = threshold.measurement + operator = threshold.operator + value = threshold.value + additionalProperties = threshold.additionalProperties.toMutableMap() + } + + /** The insight name to be evaluated. */ + fun insightName(insightName: String) = insightName(JsonField.of(insightName)) + + /** + * Sets [Builder.insightName] to an arbitrary JSON value. + * + * You should usually call [Builder.insightName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun insightName(insightName: JsonField) = apply { + this.insightName = insightName + } + + fun insightParameters(insightParameters: List) = + insightParameters(JsonField.of(insightParameters)) + + /** + * Sets [Builder.insightParameters] to an arbitrary JSON value. + * + * You should usually call [Builder.insightParameters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun insightParameters(insightParameters: JsonField>) = apply { + this.insightParameters = insightParameters.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [insightParameters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInsightParameter(insightParameter: JsonValue) = apply { + insightParameters = + (insightParameters ?: JsonField.of(mutableListOf())).also { + checkKnown("insightParameters", it).add(insightParameter) + } + } + + /** The measurement to be evaluated. */ + fun measurement(measurement: String) = measurement(JsonField.of(measurement)) + + /** + * Sets [Builder.measurement] to an arbitrary JSON value. + * + * You should usually call [Builder.measurement] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun measurement(measurement: JsonField) = apply { + this.measurement = measurement + } + + /** The operator to be used for the evaluation. */ + fun operator(operator: String) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The value to be compared. */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofStrings(strings)`. */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Threshold]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Threshold = + Threshold( + insightName, + (insightParameters ?: JsonMissing.of()).map { it.toImmutable() }, + measurement, + operator, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Threshold = apply { + if (validated) { + return@apply + } + + insightName() + insightParameters() + measurement() + operator() + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (insightName.asKnown().isPresent) 1 else 0) + + (insightParameters.asKnown().getOrNull()?.size ?: 0) + + (if (measurement.asKnown().isPresent) 1 else 0) + + (if (operator.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** The value to be compared. */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + + override fun visitStrings(strings: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Value && number == other.number && bool == other.bool && string == other.string && strings == other.strings /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(number, bool, string, strings) /* spotless:on */ + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) + } + + /** + * An interface that defines how to map each variant of [Value] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws OpenlayerInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenlayerInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Threshold && insightName == other.insightName && insightParameters == other.insightParameters && measurement == other.measurement && operator == other.operator && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(insightName, insightParameters, measurement, operator, value, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Threshold{insightName=$insightName, insightParameters=$insightParameters, measurement=$measurement, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Goal && id == other.id && commentCount == other.commentCount && creatorId == other.creatorId && dateArchived == other.dateArchived && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && name == other.name && number == other.number && originProjectVersionId == other.originProjectVersionId && subtype == other.subtype && suggested == other.suggested && thresholds == other.thresholds && type == other.type && archived == other.archived && delayWindow == other.delayWindow && evaluationWindow == other.evaluationWindow && usesMlModel == other.usesMlModel && usesProductionData == other.usesProductionData && usesReferenceDataset == other.usesReferenceDataset && usesTrainingDataset == other.usesTrainingDataset && usesValidationDataset == other.usesValidationDataset && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, commentCount, creatorId, dateArchived, dateCreated, dateUpdated, description, name, number, originProjectVersionId, subtype, suggested, thresholds, type, archived, delayWindow, evaluationWindow, usesMlModel, usesProductionData, usesReferenceDataset, usesTrainingDataset, usesValidationDataset, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Goal{id=$id, commentCount=$commentCount, creatorId=$creatorId, dateArchived=$dateArchived, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, name=$name, number=$number, originProjectVersionId=$originProjectVersionId, subtype=$subtype, suggested=$suggested, thresholds=$thresholds, type=$type, archived=$archived, delayWindow=$delayWindow, evaluationWindow=$evaluationWindow, usesMlModel=$usesMlModel, usesProductionData=$usesProductionData, usesReferenceDataset=$usesReferenceDataset, usesTrainingDataset=$usesTrainingDataset, usesValidationDataset=$usesValidationDataset, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Item && id == other.id && dateCreated == other.dateCreated && dateDataEnds == other.dateDataEnds && dateDataStarts == other.dateDataStarts && dateUpdated == other.dateUpdated && inferencePipelineId == other.inferencePipelineId && projectVersionId == other.projectVersionId && status == other.status && statusMessage == other.statusMessage && goal == other.goal && goalId == other.goalId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateDataEnds, dateDataStarts, dateUpdated, inferencePipelineId, projectVersionId, status, statusMessage, goal, goalId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, dateCreated=$dateCreated, dateDataEnds=$dateDataEnds, dateDataStarts=$dateDataStarts, dateUpdated=$dateUpdated, inferencePipelineId=$inferencePipelineId, projectVersionId=$projectVersionId, status=$status, statusMessage=$statusMessage, goal=$goal, goalId=$goalId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TestResultListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TestResultListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDeleteParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineDeleteParams.kt similarity index 85% rename from openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDeleteParams.kt rename to openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineDeleteParams.kt index 8046a965..f1034953 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineDeleteParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineDeleteParams.kt @@ -1,56 +1,51 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import com.openlayer.api.core.toImmutable import java.util.Objects import java.util.Optional +/** Delete inference pipeline. */ class InferencePipelineDeleteParams -constructor( +private constructor( private val inferencePipelineId: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { fun inferencePipelineId(): String = inferencePipelineId - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + fun _additionalHeaders(): Headers = additionalHeaders - fun getPathParam(index: Int): String { - return when (index) { - 0 -> inferencePipelineId - else -> "" - } - } + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [InferencePipelineDeleteParams]. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + */ @JvmStatic fun builder() = Builder() } - @NoAutoDetect - class Builder { + /** A builder for [InferencePipelineDeleteParams]. */ + class Builder internal constructor() { private var inferencePipelineId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -190,17 +185,40 @@ constructor( keys.forEach(::removeAdditionalBodyProperty) } + /** + * Returns an immutable instance of [InferencePipelineDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InferencePipelineDeleteParams = InferencePipelineDeleteParams( - checkNotNull(inferencePipelineId) { - "`inferencePipelineId` is required but was not set" - }, + checkRequired("inferencePipelineId", inferencePipelineId), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRetrieveParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt similarity index 60% rename from openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRetrieveParams.kt rename to openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt index b5e6d1cd..b437b9f2 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRetrieveParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt @@ -1,63 +1,59 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines import com.fasterxml.jackson.annotation.JsonCreator import com.openlayer.api.core.Enum import com.openlayer.api.core.JsonField -import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import com.openlayer.api.core.toImmutable import com.openlayer.api.errors.OpenlayerInvalidDataException import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull +/** Retrieve inference pipeline. */ class InferencePipelineRetrieveParams -constructor( +private constructor( private val inferencePipelineId: String, private val expand: List?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun inferencePipelineId(): String = inferencePipelineId + /** Expand specific nested objects. */ fun expand(): Optional> = Optional.ofNullable(expand) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.expand?.let { queryParams.put("expand", listOf(it.joinToString(separator = ","))) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> inferencePipelineId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of + * [InferencePipelineRetrieveParams]. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + */ @JvmStatic fun builder() = Builder() } - @NoAutoDetect - class Builder { + /** A builder for [InferencePipelineRetrieveParams]. */ + class Builder internal constructor() { private var inferencePipelineId: String? = null - private var expand: MutableList = mutableListOf() + private var expand: MutableList? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -65,7 +61,7 @@ constructor( internal fun from(inferencePipelineRetrieveParams: InferencePipelineRetrieveParams) = apply { inferencePipelineId = inferencePipelineRetrieveParams.inferencePipelineId - expand = inferencePipelineRetrieveParams.expand?.toMutableList() ?: mutableListOf() + expand = inferencePipelineRetrieveParams.expand?.toMutableList() additionalHeaders = inferencePipelineRetrieveParams.additionalHeaders.toBuilder() additionalQueryParams = inferencePipelineRetrieveParams.additionalQueryParams.toBuilder() @@ -76,14 +72,20 @@ constructor( } /** Expand specific nested objects. */ - fun expand(expand: List) = apply { - this.expand.clear() - this.expand.addAll(expand) + fun expand(expand: List?) = apply { this.expand = expand?.toMutableList() } + + /** Alias for calling [Builder.expand] with `expand.orElse(null)`. */ + fun expand(expand: Optional>) = expand(expand.getOrNull()) + + /** + * Adds a single [Expand] to [Builder.expand]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExpand(expand: Expand) = apply { + this.expand = (this.expand ?: mutableListOf()).apply { add(expand) } } - /** Expand specific nested objects. */ - fun addExpand(expand: Expand) = apply { this.expand.add(expand) } - fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -182,23 +184,53 @@ constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [InferencePipelineRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ fun build(): InferencePipelineRetrieveParams = InferencePipelineRetrieveParams( - checkNotNull(inferencePipelineId) { - "`inferencePipelineId` is required but was not set" - }, - expand.toImmutable().ifEmpty { null }, + checkRequired("inferencePipelineId", inferencePipelineId), + expand?.toImmutable(), additionalHeaders.build(), additionalQueryParams.build(), ) } - class Expand - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + expand?.let { put("expand", it.joinToString(",") { it.toString() }) } + putAll(additionalQueryParams) + } + .build() + + class Expand @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 { @@ -210,17 +242,35 @@ constructor( @JvmStatic fun of(value: String) = Expand(JsonField.of(value)) } + /** An enum containing [Expand]'s known values. */ enum class Known { PROJECT, WORKSPACE, } + /** + * An enum containing [Expand]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Expand] 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 { PROJECT, WORKSPACE, + /** An enum member indicating that [Expand] 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) { PROJECT -> Value.PROJECT @@ -228,6 +278,15 @@ constructor( 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { PROJECT -> Known.PROJECT @@ -235,7 +294,46 @@ constructor( else -> throw OpenlayerInvalidDataException("Unknown Expand: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Expand = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) { diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt new file mode 100644 index 00000000..75ca452b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt @@ -0,0 +1,4227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InferencePipelineRetrieveResponse +private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateLastEvaluated: JsonField, + private val dateLastSampleReceived: JsonField, + private val dateOfNextEvaluation: JsonField, + private val dateUpdated: JsonField, + private val description: JsonField, + private val failingGoalCount: JsonField, + private val links: JsonField, + private val name: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val totalGoalCount: JsonField, + private val project: JsonField, + private val workspace: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + dateLastEvaluated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + dateLastSampleReceived: JsonField = JsonMissing.of(), + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + dateOfNextEvaluation: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("project") @ExcludeMissing project: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateLastEvaluated, + dateLastSampleReceived, + dateOfNextEvaluation, + dateUpdated, + description, + failingGoalCount, + links, + name, + passingGoalCount, + projectId, + status, + statusMessage, + totalGoalCount, + project, + workspace, + workspaceId, + mutableMapOf(), + ) + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastEvaluated(): Optional = + dateLastEvaluated.getOptional("dateLastEvaluated") + + /** + * The last data sample received date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastSampleReceived(): Optional = + dateLastSampleReceived.getOptional("dateLastSampleReceived") + + /** + * The next test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateOfNextEvaluation(): Optional = + dateOfNextEvaluation.getOptional("dateOfNextEvaluation") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The number of tests failing. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of tests passing. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The status of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The total number of tests. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspace(): Optional = workspace.getOptional("workspace") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateLastEvaluated]. + * + * Unlike [dateLastEvaluated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + fun _dateLastEvaluated(): JsonField = dateLastEvaluated + + /** + * Returns the raw JSON value of [dateLastSampleReceived]. + * + * Unlike [dateLastSampleReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun _dateLastSampleReceived(): JsonField = dateLastSampleReceived + + /** + * Returns the raw JSON value of [dateOfNextEvaluation]. + * + * Unlike [dateOfNextEvaluation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun _dateOfNextEvaluation(): JsonField = dateOfNextEvaluation + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * 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 [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") @ExcludeMissing fun _workspace(): JsonField = workspace + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId(): JsonField = workspaceId + + @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 + * [InferencePipelineRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateLastEvaluated: JsonField? = null + private var dateLastSampleReceived: JsonField? = null + private var dateOfNextEvaluation: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonField? = null + private var failingGoalCount: JsonField? = null + private var links: JsonField? = null + private var name: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var totalGoalCount: JsonField? = null + private var project: JsonField = JsonMissing.of() + private var workspace: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineRetrieveResponse: InferencePipelineRetrieveResponse) = + apply { + id = inferencePipelineRetrieveResponse.id + dateCreated = inferencePipelineRetrieveResponse.dateCreated + dateLastEvaluated = inferencePipelineRetrieveResponse.dateLastEvaluated + dateLastSampleReceived = inferencePipelineRetrieveResponse.dateLastSampleReceived + dateOfNextEvaluation = inferencePipelineRetrieveResponse.dateOfNextEvaluation + dateUpdated = inferencePipelineRetrieveResponse.dateUpdated + description = inferencePipelineRetrieveResponse.description + failingGoalCount = inferencePipelineRetrieveResponse.failingGoalCount + links = inferencePipelineRetrieveResponse.links + name = inferencePipelineRetrieveResponse.name + passingGoalCount = inferencePipelineRetrieveResponse.passingGoalCount + projectId = inferencePipelineRetrieveResponse.projectId + status = inferencePipelineRetrieveResponse.status + statusMessage = inferencePipelineRetrieveResponse.statusMessage + totalGoalCount = inferencePipelineRetrieveResponse.totalGoalCount + project = inferencePipelineRetrieveResponse.project + workspace = inferencePipelineRetrieveResponse.workspace + workspaceId = inferencePipelineRetrieveResponse.workspaceId + additionalProperties = + inferencePipelineRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The inference pipeline id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime?) = + dateLastEvaluated(JsonField.ofNullable(dateLastEvaluated)) + + /** Alias for calling [Builder.dateLastEvaluated] with `dateLastEvaluated.orElse(null)`. */ + fun dateLastEvaluated(dateLastEvaluated: Optional) = + dateLastEvaluated(dateLastEvaluated.getOrNull()) + + /** + * Sets [Builder.dateLastEvaluated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastEvaluated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + this.dateLastEvaluated = dateLastEvaluated + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime?) = + dateLastSampleReceived(JsonField.ofNullable(dateLastSampleReceived)) + + /** + * Alias for calling [Builder.dateLastSampleReceived] with + * `dateLastSampleReceived.orElse(null)`. + */ + fun dateLastSampleReceived(dateLastSampleReceived: Optional) = + dateLastSampleReceived(dateLastSampleReceived.getOrNull()) + + /** + * Sets [Builder.dateLastSampleReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastSampleReceived] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + this.dateLastSampleReceived = dateLastSampleReceived + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime?) = + dateOfNextEvaluation(JsonField.ofNullable(dateOfNextEvaluation)) + + /** + * Alias for calling [Builder.dateOfNextEvaluation] with + * `dateOfNextEvaluation.orElse(null)`. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: Optional) = + dateOfNextEvaluation(dateOfNextEvaluation.getOrNull()) + + /** + * Sets [Builder.dateOfNextEvaluation] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfNextEvaluation] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + this.dateOfNextEvaluation = dateOfNextEvaluation + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The inference pipeline name. */ + 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 } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + fun project(project: Project?) = project(JsonField.ofNullable(project)) + + /** Alias for calling [Builder.project] with `project.orElse(null)`. */ + fun project(project: Optional) = project(project.getOrNull()) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [Project] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun workspace(workspace: Workspace?) = workspace(JsonField.ofNullable(workspace)) + + /** Alias for calling [Builder.workspace] with `workspace.orElse(null)`. */ + fun workspace(workspace: Optional) = workspace(workspace.getOrNull()) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + /** The workspace id. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InferencePipelineRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InferencePipelineRetrieveResponse = + InferencePipelineRetrieveResponse( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateLastEvaluated", dateLastEvaluated), + checkRequired("dateLastSampleReceived", dateLastSampleReceived), + checkRequired("dateOfNextEvaluation", dateOfNextEvaluation), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("links", links), + checkRequired("name", name), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("totalGoalCount", totalGoalCount), + project, + workspace, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InferencePipelineRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateLastEvaluated() + dateLastSampleReceived() + dateOfNextEvaluation() + dateUpdated() + description() + failingGoalCount() + links().validate() + name() + passingGoalCount() + projectId() + status().validate() + statusMessage() + totalGoalCount() + project().ifPresent { it.validate() } + workspace().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The status of test evaluation for the inference pipeline. */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Project + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 [Project]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Project]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(project: Project) = apply { + id = project.id + creatorId = project.creatorId + dateCreated = project.dateCreated + dateUpdated = project.dateUpdated + developmentGoalCount = project.developmentGoalCount + goalCount = project.goalCount + inferencePipelineCount = project.inferencePipelineCount + links = project.links + monitoringGoalCount = project.monitoringGoalCount + name = project.name + source = project.source + taskType = project.taskType + versionCount = project.versionCount + workspaceId = project.workspaceId + description = project.description + gitRepo = project.gitRepo + additionalProperties = project.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Project]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Project = + Project( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Project = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** + * An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** + * An enum member indicating that [TaskType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") + @ExcludeMissing + rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Project && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Project{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + class Workspace + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException 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 inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException 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 memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodEndDate(): Optional = periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodStartDate(): Optional = + periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException 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 projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = + wildcardDomains.getOptional("wildcardDomains") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCount") + @ExcludeMissing + fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * 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 [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") + @ExcludeMissing + fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @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 [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + creatorId = workspace.creatorId + dateCreated = workspace.dateCreated + dateUpdated = workspace.dateUpdated + inviteCount = workspace.inviteCount + memberCount = workspace.memberCount + name = workspace.name + periodEndDate = workspace.periodEndDate + periodStartDate = workspace.periodStartDate + projectCount = workspace.projectCount + slug = workspace.slug + status = workspace.status + inviteCode = workspace.inviteCode + monthlyUsage = workspace.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspace.samlOnlyAccess + wildcardDomains = workspace.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + 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 } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** The workspace name. */ + 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 } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectCount(projectCount: JsonField) = apply { + this.projectCount = projectCount + } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = + samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** + * An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionCount(): Optional = predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @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 [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = + executionTimeMs(executionTimeMs as Long?) + + /** + * Alias for calling [Builder.executionTimeMs] with `executionTimeMs.orElse(null)`. + */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun monthYear(monthYear: JsonField) = apply { + this.monthYear = monthYear + } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MonthlyUsage && executionTimeMs == other.executionTimeMs && monthYear == other.monthYear && predictionCount == other.predictionCount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Workspace && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && inviteCount == other.inviteCount && memberCount == other.memberCount && name == other.name && periodEndDate == other.periodEndDate && periodStartDate == other.periodStartDate && projectCount == other.projectCount && slug == other.slug && status == other.status && inviteCode == other.inviteCode && monthlyUsage == other.monthlyUsage && samlOnlyAccess == other.samlOnlyAccess && wildcardDomains == other.wildcardDomains && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, inviteCount, memberCount, name, periodEndDate, periodStartDate, projectCount, slug, status, inviteCode, monthlyUsage, samlOnlyAccess, wildcardDomains, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineRetrieveResponse && id == other.id && dateCreated == other.dateCreated && dateLastEvaluated == other.dateLastEvaluated && dateLastSampleReceived == other.dateLastSampleReceived && dateOfNextEvaluation == other.dateOfNextEvaluation && dateUpdated == other.dateUpdated && description == other.description && failingGoalCount == other.failingGoalCount && links == other.links && name == other.name && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && totalGoalCount == other.totalGoalCount && project == other.project && workspace == other.workspace && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateLastEvaluated, dateLastSampleReceived, dateOfNextEvaluation, dateUpdated, description, failingGoalCount, links, name, passingGoalCount, projectId, status, statusMessage, totalGoalCount, project, workspace, workspaceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InferencePipelineRetrieveResponse{id=$id, dateCreated=$dateCreated, dateLastEvaluated=$dateLastEvaluated, dateLastSampleReceived=$dateLastSampleReceived, dateOfNextEvaluation=$dateOfNextEvaluation, dateUpdated=$dateUpdated, description=$description, failingGoalCount=$failingGoalCount, links=$links, name=$name, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, totalGoalCount=$totalGoalCount, project=$project, workspace=$workspace, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt new file mode 100644 index 00000000..26cd8180 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt @@ -0,0 +1,585 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +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.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update inference pipeline. */ +class InferencePipelineUpdateParams +private constructor( + private val inferencePipelineId: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun inferencePipelineId(): String = inferencePipelineId + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to + * handle your reference dataset updates. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun referenceDatasetUri(): Optional = body.referenceDatasetUri() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * 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 [referenceDatasetUri]. + * + * Unlike [referenceDatasetUri], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _referenceDatasetUri(): JsonField = body._referenceDatasetUri() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InferencePipelineUpdateParams]. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineUpdateParams]. */ + class Builder internal constructor() { + + private var inferencePipelineId: 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(inferencePipelineUpdateParams: InferencePipelineUpdateParams) = apply { + inferencePipelineId = inferencePipelineUpdateParams.inferencePipelineId + body = inferencePipelineUpdateParams.body.toBuilder() + additionalHeaders = inferencePipelineUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = inferencePipelineUpdateParams.additionalQueryParams.toBuilder() + } + + fun inferencePipelineId(inferencePipelineId: String) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** + * 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: + * - [description] + * - [name] + * - [referenceDatasetUri] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The inference pipeline description. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** The inference pipeline name. */ + 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) } + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to + * handle your reference dataset updates. + */ + fun referenceDatasetUri(referenceDatasetUri: String?) = apply { + body.referenceDatasetUri(referenceDatasetUri) + } + + /** + * Alias for calling [Builder.referenceDatasetUri] with `referenceDatasetUri.orElse(null)`. + */ + fun referenceDatasetUri(referenceDatasetUri: Optional) = + referenceDatasetUri(referenceDatasetUri.getOrNull()) + + /** + * Sets [Builder.referenceDatasetUri] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun referenceDatasetUri(referenceDatasetUri: JsonField) = apply { + body.referenceDatasetUri(referenceDatasetUri) + } + + 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 [InferencePipelineUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InferencePipelineUpdateParams = + InferencePipelineUpdateParams( + checkRequired("inferencePipelineId", inferencePipelineId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val description: JsonField, + private val name: JsonField, + private val referenceDatasetUri: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("referenceDatasetUri") + @ExcludeMissing + referenceDatasetUri: JsonField = JsonMissing.of(), + ) : this(description, name, referenceDatasetUri, mutableMapOf()) + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to + * handle your reference dataset updates. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun referenceDatasetUri(): Optional = + referenceDatasetUri.getOptional("referenceDatasetUri") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * 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 [referenceDatasetUri]. + * + * Unlike [referenceDatasetUri], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("referenceDatasetUri") + @ExcludeMissing + fun _referenceDatasetUri(): JsonField = referenceDatasetUri + + @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 description: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var referenceDatasetUri: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + name = body.name + referenceDatasetUri = body.referenceDatasetUri + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The inference pipeline description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The inference pipeline name. */ + 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 } + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the + * UI to handle your reference dataset updates. + */ + fun referenceDatasetUri(referenceDatasetUri: String?) = + referenceDatasetUri(JsonField.ofNullable(referenceDatasetUri)) + + /** + * Alias for calling [Builder.referenceDatasetUri] with + * `referenceDatasetUri.orElse(null)`. + */ + fun referenceDatasetUri(referenceDatasetUri: Optional) = + referenceDatasetUri(referenceDatasetUri.getOrNull()) + + /** + * Sets [Builder.referenceDatasetUri] to an arbitrary JSON value. + * + * You should usually call [Builder.referenceDatasetUri] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun referenceDatasetUri(referenceDatasetUri: JsonField) = apply { + this.referenceDatasetUri = referenceDatasetUri + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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(description, name, referenceDatasetUri, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + name() + referenceDatasetUri() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetUri.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && description == other.description && name == other.name && referenceDatasetUri == other.referenceDatasetUri && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(description, name, referenceDatasetUri, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, name=$name, referenceDatasetUri=$referenceDatasetUri, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineUpdateParams && inferencePipelineId == other.inferencePipelineId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "InferencePipelineUpdateParams{inferencePipelineId=$inferencePipelineId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt new file mode 100644 index 00000000..af87f6ae --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt @@ -0,0 +1,4227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InferencePipelineUpdateResponse +private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateLastEvaluated: JsonField, + private val dateLastSampleReceived: JsonField, + private val dateOfNextEvaluation: JsonField, + private val dateUpdated: JsonField, + private val description: JsonField, + private val failingGoalCount: JsonField, + private val links: JsonField, + private val name: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val totalGoalCount: JsonField, + private val project: JsonField, + private val workspace: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + dateLastEvaluated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + dateLastSampleReceived: JsonField = JsonMissing.of(), + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + dateOfNextEvaluation: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("project") @ExcludeMissing project: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateLastEvaluated, + dateLastSampleReceived, + dateOfNextEvaluation, + dateUpdated, + description, + failingGoalCount, + links, + name, + passingGoalCount, + projectId, + status, + statusMessage, + totalGoalCount, + project, + workspace, + workspaceId, + mutableMapOf(), + ) + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastEvaluated(): Optional = + dateLastEvaluated.getOptional("dateLastEvaluated") + + /** + * The last data sample received date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastSampleReceived(): Optional = + dateLastSampleReceived.getOptional("dateLastSampleReceived") + + /** + * The next test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateOfNextEvaluation(): Optional = + dateOfNextEvaluation.getOptional("dateOfNextEvaluation") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The number of tests failing. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of tests passing. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The status of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The total number of tests. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspace(): Optional = workspace.getOptional("workspace") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateLastEvaluated]. + * + * Unlike [dateLastEvaluated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + fun _dateLastEvaluated(): JsonField = dateLastEvaluated + + /** + * Returns the raw JSON value of [dateLastSampleReceived]. + * + * Unlike [dateLastSampleReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun _dateLastSampleReceived(): JsonField = dateLastSampleReceived + + /** + * Returns the raw JSON value of [dateOfNextEvaluation]. + * + * Unlike [dateOfNextEvaluation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun _dateOfNextEvaluation(): JsonField = dateOfNextEvaluation + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * 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 [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") @ExcludeMissing fun _workspace(): JsonField = workspace + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId(): JsonField = workspaceId + + @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 + * [InferencePipelineUpdateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineUpdateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateLastEvaluated: JsonField? = null + private var dateLastSampleReceived: JsonField? = null + private var dateOfNextEvaluation: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonField? = null + private var failingGoalCount: JsonField? = null + private var links: JsonField? = null + private var name: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var totalGoalCount: JsonField? = null + private var project: JsonField = JsonMissing.of() + private var workspace: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineUpdateResponse: InferencePipelineUpdateResponse) = + apply { + id = inferencePipelineUpdateResponse.id + dateCreated = inferencePipelineUpdateResponse.dateCreated + dateLastEvaluated = inferencePipelineUpdateResponse.dateLastEvaluated + dateLastSampleReceived = inferencePipelineUpdateResponse.dateLastSampleReceived + dateOfNextEvaluation = inferencePipelineUpdateResponse.dateOfNextEvaluation + dateUpdated = inferencePipelineUpdateResponse.dateUpdated + description = inferencePipelineUpdateResponse.description + failingGoalCount = inferencePipelineUpdateResponse.failingGoalCount + links = inferencePipelineUpdateResponse.links + name = inferencePipelineUpdateResponse.name + passingGoalCount = inferencePipelineUpdateResponse.passingGoalCount + projectId = inferencePipelineUpdateResponse.projectId + status = inferencePipelineUpdateResponse.status + statusMessage = inferencePipelineUpdateResponse.statusMessage + totalGoalCount = inferencePipelineUpdateResponse.totalGoalCount + project = inferencePipelineUpdateResponse.project + workspace = inferencePipelineUpdateResponse.workspace + workspaceId = inferencePipelineUpdateResponse.workspaceId + additionalProperties = + inferencePipelineUpdateResponse.additionalProperties.toMutableMap() + } + + /** The inference pipeline id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime?) = + dateLastEvaluated(JsonField.ofNullable(dateLastEvaluated)) + + /** Alias for calling [Builder.dateLastEvaluated] with `dateLastEvaluated.orElse(null)`. */ + fun dateLastEvaluated(dateLastEvaluated: Optional) = + dateLastEvaluated(dateLastEvaluated.getOrNull()) + + /** + * Sets [Builder.dateLastEvaluated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastEvaluated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + this.dateLastEvaluated = dateLastEvaluated + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime?) = + dateLastSampleReceived(JsonField.ofNullable(dateLastSampleReceived)) + + /** + * Alias for calling [Builder.dateLastSampleReceived] with + * `dateLastSampleReceived.orElse(null)`. + */ + fun dateLastSampleReceived(dateLastSampleReceived: Optional) = + dateLastSampleReceived(dateLastSampleReceived.getOrNull()) + + /** + * Sets [Builder.dateLastSampleReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastSampleReceived] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + this.dateLastSampleReceived = dateLastSampleReceived + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime?) = + dateOfNextEvaluation(JsonField.ofNullable(dateOfNextEvaluation)) + + /** + * Alias for calling [Builder.dateOfNextEvaluation] with + * `dateOfNextEvaluation.orElse(null)`. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: Optional) = + dateOfNextEvaluation(dateOfNextEvaluation.getOrNull()) + + /** + * Sets [Builder.dateOfNextEvaluation] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfNextEvaluation] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + this.dateOfNextEvaluation = dateOfNextEvaluation + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The inference pipeline name. */ + 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 } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + fun project(project: Project?) = project(JsonField.ofNullable(project)) + + /** Alias for calling [Builder.project] with `project.orElse(null)`. */ + fun project(project: Optional) = project(project.getOrNull()) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [Project] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun workspace(workspace: Workspace?) = workspace(JsonField.ofNullable(workspace)) + + /** Alias for calling [Builder.workspace] with `workspace.orElse(null)`. */ + fun workspace(workspace: Optional) = workspace(workspace.getOrNull()) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + /** The workspace id. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InferencePipelineUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InferencePipelineUpdateResponse = + InferencePipelineUpdateResponse( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateLastEvaluated", dateLastEvaluated), + checkRequired("dateLastSampleReceived", dateLastSampleReceived), + checkRequired("dateOfNextEvaluation", dateOfNextEvaluation), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("links", links), + checkRequired("name", name), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("totalGoalCount", totalGoalCount), + project, + workspace, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InferencePipelineUpdateResponse = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateLastEvaluated() + dateLastSampleReceived() + dateOfNextEvaluation() + dateUpdated() + description() + failingGoalCount() + links().validate() + name() + passingGoalCount() + projectId() + status().validate() + statusMessage() + totalGoalCount() + project().ifPresent { it.validate() } + workspace().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The status of test evaluation for the inference pipeline. */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Project + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 [Project]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Project]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(project: Project) = apply { + id = project.id + creatorId = project.creatorId + dateCreated = project.dateCreated + dateUpdated = project.dateUpdated + developmentGoalCount = project.developmentGoalCount + goalCount = project.goalCount + inferencePipelineCount = project.inferencePipelineCount + links = project.links + monitoringGoalCount = project.monitoringGoalCount + name = project.name + source = project.source + taskType = project.taskType + versionCount = project.versionCount + workspaceId = project.workspaceId + description = project.description + gitRepo = project.gitRepo + additionalProperties = project.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Project]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Project = + Project( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Project = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** + * An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** + * An enum member indicating that [TaskType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") + @ExcludeMissing + rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Project && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Project{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + class Workspace + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException 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 inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException 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 memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodEndDate(): Optional = periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodStartDate(): Optional = + periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException 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 projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = + wildcardDomains.getOptional("wildcardDomains") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCount") + @ExcludeMissing + fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * 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 [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") + @ExcludeMissing + fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @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 [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + creatorId = workspace.creatorId + dateCreated = workspace.dateCreated + dateUpdated = workspace.dateUpdated + inviteCount = workspace.inviteCount + memberCount = workspace.memberCount + name = workspace.name + periodEndDate = workspace.periodEndDate + periodStartDate = workspace.periodStartDate + projectCount = workspace.projectCount + slug = workspace.slug + status = workspace.status + inviteCode = workspace.inviteCode + monthlyUsage = workspace.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspace.samlOnlyAccess + wildcardDomains = workspace.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + 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 } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** The workspace name. */ + 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 } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectCount(projectCount: JsonField) = apply { + this.projectCount = projectCount + } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = + samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** + * An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionCount(): Optional = predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @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 [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = + executionTimeMs(executionTimeMs as Long?) + + /** + * Alias for calling [Builder.executionTimeMs] with `executionTimeMs.orElse(null)`. + */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun monthYear(monthYear: JsonField) = apply { + this.monthYear = monthYear + } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MonthlyUsage && executionTimeMs == other.executionTimeMs && monthYear == other.monthYear && predictionCount == other.predictionCount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Workspace && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && inviteCount == other.inviteCount && memberCount == other.memberCount && name == other.name && periodEndDate == other.periodEndDate && periodStartDate == other.periodStartDate && projectCount == other.projectCount && slug == other.slug && status == other.status && inviteCode == other.inviteCode && monthlyUsage == other.monthlyUsage && samlOnlyAccess == other.samlOnlyAccess && wildcardDomains == other.wildcardDomains && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, inviteCount, memberCount, name, periodEndDate, periodStartDate, projectCount, slug, status, inviteCode, monthlyUsage, samlOnlyAccess, wildcardDomains, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineUpdateResponse && id == other.id && dateCreated == other.dateCreated && dateLastEvaluated == other.dateLastEvaluated && dateLastSampleReceived == other.dateLastSampleReceived && dateOfNextEvaluation == other.dateOfNextEvaluation && dateUpdated == other.dateUpdated && description == other.description && failingGoalCount == other.failingGoalCount && links == other.links && name == other.name && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && totalGoalCount == other.totalGoalCount && project == other.project && workspace == other.workspace && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateLastEvaluated, dateLastSampleReceived, dateOfNextEvaluation, dateUpdated, description, failingGoalCount, links, name, passingGoalCount, projectId, status, statusMessage, totalGoalCount, project, workspace, workspaceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InferencePipelineUpdateResponse{id=$id, dateCreated=$dateCreated, dateLastEvaluated=$dateLastEvaluated, dateLastSampleReceived=$dateLastSampleReceived, dateOfNextEvaluation=$dateOfNextEvaluation, dateUpdated=$dateUpdated, description=$description, failingGoalCount=$failingGoalCount, links=$links, name=$name, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, totalGoalCount=$totalGoalCount, project=$project, workspace=$workspace, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt new file mode 100644 index 00000000..9d246237 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt @@ -0,0 +1,3399 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.data + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.BaseDeserializer +import com.openlayer.api.core.BaseSerializer +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.allMaxBy +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.getOrThrow +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Publish an inference data point to an inference pipeline. */ +class DataStreamParams +private constructor( + private val inferencePipelineId: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun inferencePipelineId(): String = inferencePipelineId + + /** + * Configuration for the data stream. Depends on your **Openlayer project task type**. + * + * @throws OpenlayerInvalidDataException 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 config(): Config = body.config() + + /** + * A list of inference data points with inputs and outputs + * + * @throws OpenlayerInvalidDataException 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 rows(): List = body.rows() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + + /** + * Returns the raw JSON value of [rows]. + * + * Unlike [rows], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rows(): JsonField> = body._rows() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DataStreamParams]. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * .config() + * .rows() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataStreamParams]. */ + class Builder internal constructor() { + + private var inferencePipelineId: 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(dataStreamParams: DataStreamParams) = apply { + inferencePipelineId = dataStreamParams.inferencePipelineId + body = dataStreamParams.body.toBuilder() + additionalHeaders = dataStreamParams.additionalHeaders.toBuilder() + additionalQueryParams = dataStreamParams.additionalQueryParams.toBuilder() + } + + fun inferencePipelineId(inferencePipelineId: String) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** + * 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: + * - [config] + * - [rows] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ + fun config(config: Config) = apply { body.config(config) } + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } + + /** Alias for calling [config] with `Config.ofLlmData(llmData)`. */ + fun config(llmData: Config.LlmData) = apply { body.config(llmData) } + + /** + * Alias for calling [config] with + * `Config.ofTabularClassificationData(tabularClassificationData)`. + */ + fun config(tabularClassificationData: Config.TabularClassificationData) = apply { + body.config(tabularClassificationData) + } + + /** + * Alias for calling [config] with `Config.ofTabularRegressionData(tabularRegressionData)`. + */ + fun config(tabularRegressionData: Config.TabularRegressionData) = apply { + body.config(tabularRegressionData) + } + + /** + * Alias for calling [config] with + * `Config.ofTextClassificationData(textClassificationData)`. + */ + fun config(textClassificationData: Config.TextClassificationData) = apply { + body.config(textClassificationData) + } + + /** A list of inference data points with inputs and outputs */ + fun rows(rows: List) = apply { body.rows(rows) } + + /** + * Sets [Builder.rows] to an arbitrary JSON value. + * + * You should usually call [Builder.rows] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun rows(rows: JsonField>) = apply { body.rows(rows) } + + /** + * Adds a single [Row] to [rows]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRow(row: Row) = apply { body.addRow(row) } + + 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 [DataStreamParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * .config() + * .rows() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DataStreamParams = + DataStreamParams( + checkRequired("inferencePipelineId", inferencePipelineId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val config: JsonField, + private val rows: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), + @JsonProperty("rows") @ExcludeMissing rows: JsonField> = JsonMissing.of(), + ) : this(config, rows, mutableMapOf()) + + /** + * Configuration for the data stream. Depends on your **Openlayer project task type**. + * + * @throws OpenlayerInvalidDataException 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 config(): Config = config.getRequired("config") + + /** + * A list of inference data points with inputs and outputs + * + * @throws OpenlayerInvalidDataException 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 rows(): List = rows.getRequired("rows") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [rows]. + * + * Unlike [rows], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rows") @ExcludeMissing fun _rows(): JsonField> = rows + + @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 + * .config() + * .rows() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField? = null + private var rows: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + rows = body.rows.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Configuration for the data stream. Depends on your **Openlayer project task type**. + */ + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + /** Alias for calling [config] with `Config.ofLlmData(llmData)`. */ + fun config(llmData: Config.LlmData) = config(Config.ofLlmData(llmData)) + + /** + * Alias for calling [config] with + * `Config.ofTabularClassificationData(tabularClassificationData)`. + */ + fun config(tabularClassificationData: Config.TabularClassificationData) = + config(Config.ofTabularClassificationData(tabularClassificationData)) + + /** + * Alias for calling [config] with + * `Config.ofTabularRegressionData(tabularRegressionData)`. + */ + fun config(tabularRegressionData: Config.TabularRegressionData) = + config(Config.ofTabularRegressionData(tabularRegressionData)) + + /** + * Alias for calling [config] with + * `Config.ofTextClassificationData(textClassificationData)`. + */ + fun config(textClassificationData: Config.TextClassificationData) = + config(Config.ofTextClassificationData(textClassificationData)) + + /** A list of inference data points with inputs and outputs */ + fun rows(rows: List) = rows(JsonField.of(rows)) + + /** + * Sets [Builder.rows] to an arbitrary JSON value. + * + * You should usually call [Builder.rows] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rows(rows: JsonField>) = apply { + this.rows = rows.map { it.toMutableList() } + } + + /** + * Adds a single [Row] to [rows]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRow(row: Row) = apply { + rows = + (rows ?: JsonField.of(mutableListOf())).also { checkKnown("rows", it).add(row) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .config() + * .rows() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("config", config), + checkRequired("rows", rows).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().validate() + rows().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (rows.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && config == other.config && rows == other.rows && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(config, rows, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, rows=$rows, additionalProperties=$additionalProperties}" + } + + /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ + @JsonDeserialize(using = Config.Deserializer::class) + @JsonSerialize(using = Config.Serializer::class) + class Config + private constructor( + private val llmData: LlmData? = null, + private val tabularClassificationData: TabularClassificationData? = null, + private val tabularRegressionData: TabularRegressionData? = null, + private val textClassificationData: TextClassificationData? = null, + private val _json: JsonValue? = null, + ) { + + fun llmData(): Optional = Optional.ofNullable(llmData) + + fun tabularClassificationData(): Optional = + Optional.ofNullable(tabularClassificationData) + + fun tabularRegressionData(): Optional = + Optional.ofNullable(tabularRegressionData) + + fun textClassificationData(): Optional = + Optional.ofNullable(textClassificationData) + + fun isLlmData(): Boolean = llmData != null + + fun isTabularClassificationData(): Boolean = tabularClassificationData != null + + fun isTabularRegressionData(): Boolean = tabularRegressionData != null + + fun isTextClassificationData(): Boolean = textClassificationData != null + + fun asLlmData(): LlmData = llmData.getOrThrow("llmData") + + fun asTabularClassificationData(): TabularClassificationData = + tabularClassificationData.getOrThrow("tabularClassificationData") + + fun asTabularRegressionData(): TabularRegressionData = + tabularRegressionData.getOrThrow("tabularRegressionData") + + fun asTextClassificationData(): TextClassificationData = + textClassificationData.getOrThrow("textClassificationData") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + llmData != null -> visitor.visitLlmData(llmData) + tabularClassificationData != null -> + visitor.visitTabularClassificationData(tabularClassificationData) + tabularRegressionData != null -> + visitor.visitTabularRegressionData(tabularRegressionData) + textClassificationData != null -> + visitor.visitTextClassificationData(textClassificationData) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitLlmData(llmData: LlmData) { + llmData.validate() + } + + override fun visitTabularClassificationData( + tabularClassificationData: TabularClassificationData + ) { + tabularClassificationData.validate() + } + + override fun visitTabularRegressionData( + tabularRegressionData: TabularRegressionData + ) { + tabularRegressionData.validate() + } + + override fun visitTextClassificationData( + textClassificationData: TextClassificationData + ) { + textClassificationData.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitLlmData(llmData: LlmData) = llmData.validity() + + override fun visitTabularClassificationData( + tabularClassificationData: TabularClassificationData + ) = tabularClassificationData.validity() + + override fun visitTabularRegressionData( + tabularRegressionData: TabularRegressionData + ) = tabularRegressionData.validity() + + override fun visitTextClassificationData( + textClassificationData: TextClassificationData + ) = textClassificationData.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Config && llmData == other.llmData && tabularClassificationData == other.tabularClassificationData && tabularRegressionData == other.tabularRegressionData && textClassificationData == other.textClassificationData /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(llmData, tabularClassificationData, tabularRegressionData, textClassificationData) /* spotless:on */ + + override fun toString(): String = + when { + llmData != null -> "Config{llmData=$llmData}" + tabularClassificationData != null -> + "Config{tabularClassificationData=$tabularClassificationData}" + tabularRegressionData != null -> + "Config{tabularRegressionData=$tabularRegressionData}" + textClassificationData != null -> + "Config{textClassificationData=$textClassificationData}" + _json != null -> "Config{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Config") + } + + companion object { + + @JvmStatic fun ofLlmData(llmData: LlmData) = Config(llmData = llmData) + + @JvmStatic + fun ofTabularClassificationData(tabularClassificationData: TabularClassificationData) = + Config(tabularClassificationData = tabularClassificationData) + + @JvmStatic + fun ofTabularRegressionData(tabularRegressionData: TabularRegressionData) = + Config(tabularRegressionData = tabularRegressionData) + + @JvmStatic + fun ofTextClassificationData(textClassificationData: TextClassificationData) = + Config(textClassificationData = textClassificationData) + } + + /** An interface that defines how to map each variant of [Config] to a value of type [T]. */ + interface Visitor { + + fun visitLlmData(llmData: LlmData): T + + fun visitTabularClassificationData( + tabularClassificationData: TabularClassificationData + ): T + + fun visitTabularRegressionData(tabularRegressionData: TabularRegressionData): T + + fun visitTextClassificationData(textClassificationData: TextClassificationData): T + + /** + * Maps an unknown variant of [Config] to a value of type [T]. + * + * An instance of [Config] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OpenlayerInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenlayerInvalidDataException("Unknown Config: $json") + } + } + + internal class Deserializer : BaseDeserializer(Config::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Config { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Config(llmData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Config(tabularClassificationData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Config(tabularRegressionData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Config(textClassificationData = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Config(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Config::class) { + + override fun serialize( + value: Config, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.llmData != null -> generator.writeObject(value.llmData) + value.tabularClassificationData != null -> + generator.writeObject(value.tabularClassificationData) + value.tabularRegressionData != null -> + generator.writeObject(value.tabularRegressionData) + value.textClassificationData != null -> + generator.writeObject(value.textClassificationData) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Config") + } + } + } + + class LlmData + private constructor( + private val outputColumnName: JsonField, + private val contextColumnName: JsonField, + private val costColumnName: JsonField, + private val groundTruthColumnName: JsonField, + private val inferenceIdColumnName: JsonField, + private val inputVariableNames: JsonField>, + private val latencyColumnName: JsonField, + private val metadata: JsonValue, + private val numOfTokenColumnName: JsonField, + private val prompt: JsonField>, + private val questionColumnName: JsonField, + private val timestampColumnName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("outputColumnName") + @ExcludeMissing + outputColumnName: JsonField = JsonMissing.of(), + @JsonProperty("contextColumnName") + @ExcludeMissing + contextColumnName: JsonField = JsonMissing.of(), + @JsonProperty("costColumnName") + @ExcludeMissing + costColumnName: JsonField = JsonMissing.of(), + @JsonProperty("groundTruthColumnName") + @ExcludeMissing + groundTruthColumnName: JsonField = JsonMissing.of(), + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + inferenceIdColumnName: JsonField = JsonMissing.of(), + @JsonProperty("inputVariableNames") + @ExcludeMissing + inputVariableNames: JsonField> = JsonMissing.of(), + @JsonProperty("latencyColumnName") + @ExcludeMissing + latencyColumnName: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("numOfTokenColumnName") + @ExcludeMissing + numOfTokenColumnName: JsonField = JsonMissing.of(), + @JsonProperty("prompt") + @ExcludeMissing + prompt: JsonField> = JsonMissing.of(), + @JsonProperty("questionColumnName") + @ExcludeMissing + questionColumnName: JsonField = JsonMissing.of(), + @JsonProperty("timestampColumnName") + @ExcludeMissing + timestampColumnName: JsonField = JsonMissing.of(), + ) : this( + outputColumnName, + contextColumnName, + costColumnName, + groundTruthColumnName, + inferenceIdColumnName, + inputVariableNames, + latencyColumnName, + metadata, + numOfTokenColumnName, + prompt, + questionColumnName, + timestampColumnName, + mutableMapOf(), + ) + + /** + * Name of the column with the model outputs. + * + * @throws OpenlayerInvalidDataException 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 outputColumnName(): String = outputColumnName.getRequired("outputColumnName") + + /** + * Name of the column with the context retrieved. Applies to RAG use cases. Providing + * the context enables RAG-specific metrics. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun contextColumnName(): Optional = + contextColumnName.getOptional("contextColumnName") + + /** + * Name of the column with the cost associated with each row. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun costColumnName(): Optional = costColumnName.getOptional("costColumnName") + + /** + * Name of the column with the ground truths. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun groundTruthColumnName(): Optional = + groundTruthColumnName.getOptional("groundTruthColumnName") + + /** + * Name of the column with the inference ids. This is useful if you want to update rows + * at a later point in time. If not provided, a unique id is generated by Openlayer. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inferenceIdColumnName(): Optional = + inferenceIdColumnName.getOptional("inferenceIdColumnName") + + /** + * Array of input variable names. Each input variable should be a dataset column. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inputVariableNames(): Optional> = + inputVariableNames.getOptional("inputVariableNames") + + /** + * Name of the column with the latencies. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun latencyColumnName(): Optional = + latencyColumnName.getOptional("latencyColumnName") + + /** Object with metadata. */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * Name of the column with the total number of tokens. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun numOfTokenColumnName(): Optional = + numOfTokenColumnName.getOptional("numOfTokenColumnName") + + /** + * Prompt for the LLM. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun prompt(): Optional> = prompt.getOptional("prompt") + + /** + * Name of the column with the questions. Applies to RAG use cases. Providing the + * question enables RAG-specific metrics. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun questionColumnName(): Optional = + questionColumnName.getOptional("questionColumnName") + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun timestampColumnName(): Optional = + timestampColumnName.getOptional("timestampColumnName") + + /** + * Returns the raw JSON value of [outputColumnName]. + * + * Unlike [outputColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("outputColumnName") + @ExcludeMissing + fun _outputColumnName(): JsonField = outputColumnName + + /** + * Returns the raw JSON value of [contextColumnName]. + * + * Unlike [contextColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contextColumnName") + @ExcludeMissing + fun _contextColumnName(): JsonField = contextColumnName + + /** + * Returns the raw JSON value of [costColumnName]. + * + * Unlike [costColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("costColumnName") + @ExcludeMissing + fun _costColumnName(): JsonField = costColumnName + + /** + * Returns the raw JSON value of [groundTruthColumnName]. + * + * Unlike [groundTruthColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("groundTruthColumnName") + @ExcludeMissing + fun _groundTruthColumnName(): JsonField = groundTruthColumnName + + /** + * Returns the raw JSON value of [inferenceIdColumnName]. + * + * Unlike [inferenceIdColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + fun _inferenceIdColumnName(): JsonField = inferenceIdColumnName + + /** + * Returns the raw JSON value of [inputVariableNames]. + * + * Unlike [inputVariableNames], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inputVariableNames") + @ExcludeMissing + fun _inputVariableNames(): JsonField> = inputVariableNames + + /** + * Returns the raw JSON value of [latencyColumnName]. + * + * Unlike [latencyColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("latencyColumnName") + @ExcludeMissing + fun _latencyColumnName(): JsonField = latencyColumnName + + /** + * Returns the raw JSON value of [numOfTokenColumnName]. + * + * Unlike [numOfTokenColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("numOfTokenColumnName") + @ExcludeMissing + fun _numOfTokenColumnName(): JsonField = numOfTokenColumnName + + /** + * Returns the raw JSON value of [prompt]. + * + * Unlike [prompt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField> = prompt + + /** + * Returns the raw JSON value of [questionColumnName]. + * + * Unlike [questionColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("questionColumnName") + @ExcludeMissing + fun _questionColumnName(): JsonField = questionColumnName + + /** + * Returns the raw JSON value of [timestampColumnName]. + * + * Unlike [timestampColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("timestampColumnName") + @ExcludeMissing + fun _timestampColumnName(): JsonField = timestampColumnName + + @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 [LlmData]. + * + * The following fields are required: + * ```java + * .outputColumnName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LlmData]. */ + class Builder internal constructor() { + + private var outputColumnName: JsonField? = null + private var contextColumnName: JsonField = JsonMissing.of() + private var costColumnName: JsonField = JsonMissing.of() + private var groundTruthColumnName: JsonField = JsonMissing.of() + private var inferenceIdColumnName: JsonField = JsonMissing.of() + private var inputVariableNames: JsonField>? = null + private var latencyColumnName: JsonField = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var numOfTokenColumnName: JsonField = JsonMissing.of() + private var prompt: JsonField>? = null + private var questionColumnName: JsonField = JsonMissing.of() + private var timestampColumnName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(llmData: LlmData) = apply { + outputColumnName = llmData.outputColumnName + contextColumnName = llmData.contextColumnName + costColumnName = llmData.costColumnName + groundTruthColumnName = llmData.groundTruthColumnName + inferenceIdColumnName = llmData.inferenceIdColumnName + inputVariableNames = llmData.inputVariableNames.map { it.toMutableList() } + latencyColumnName = llmData.latencyColumnName + metadata = llmData.metadata + numOfTokenColumnName = llmData.numOfTokenColumnName + prompt = llmData.prompt.map { it.toMutableList() } + questionColumnName = llmData.questionColumnName + timestampColumnName = llmData.timestampColumnName + additionalProperties = llmData.additionalProperties.toMutableMap() + } + + /** Name of the column with the model outputs. */ + fun outputColumnName(outputColumnName: String) = + outputColumnName(JsonField.of(outputColumnName)) + + /** + * Sets [Builder.outputColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.outputColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun outputColumnName(outputColumnName: JsonField) = apply { + this.outputColumnName = outputColumnName + } + + /** + * Name of the column with the context retrieved. Applies to RAG use cases. + * Providing the context enables RAG-specific metrics. + */ + fun contextColumnName(contextColumnName: String) = + contextColumnName(JsonField.of(contextColumnName)) + + /** + * Sets [Builder.contextColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.contextColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun contextColumnName(contextColumnName: JsonField) = apply { + this.contextColumnName = contextColumnName + } + + /** Name of the column with the cost associated with each row. */ + fun costColumnName(costColumnName: String) = + costColumnName(JsonField.of(costColumnName)) + + /** + * Sets [Builder.costColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.costColumnName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun costColumnName(costColumnName: JsonField) = apply { + this.costColumnName = costColumnName + } + + /** Name of the column with the ground truths. */ + fun groundTruthColumnName(groundTruthColumnName: String) = + groundTruthColumnName(JsonField.of(groundTruthColumnName)) + + /** + * Sets [Builder.groundTruthColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.groundTruthColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun groundTruthColumnName(groundTruthColumnName: JsonField) = apply { + this.groundTruthColumnName = groundTruthColumnName + } + + /** + * Name of the column with the inference ids. This is useful if you want to update + * rows at a later point in time. If not provided, a unique id is generated by + * Openlayer. + */ + fun inferenceIdColumnName(inferenceIdColumnName: String) = + inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) + + /** + * Sets [Builder.inferenceIdColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.inferenceIdColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { + this.inferenceIdColumnName = inferenceIdColumnName + } + + /** + * Array of input variable names. Each input variable should be a dataset column. + */ + fun inputVariableNames(inputVariableNames: List) = + inputVariableNames(JsonField.of(inputVariableNames)) + + /** + * Sets [Builder.inputVariableNames] to an arbitrary JSON value. + * + * You should usually call [Builder.inputVariableNames] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inputVariableNames(inputVariableNames: JsonField>) = apply { + this.inputVariableNames = inputVariableNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [inputVariableNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInputVariableName(inputVariableName: String) = apply { + inputVariableNames = + (inputVariableNames ?: JsonField.of(mutableListOf())).also { + checkKnown("inputVariableNames", it).add(inputVariableName) + } + } + + /** Name of the column with the latencies. */ + fun latencyColumnName(latencyColumnName: String) = + latencyColumnName(JsonField.of(latencyColumnName)) + + /** + * Sets [Builder.latencyColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun latencyColumnName(latencyColumnName: JsonField) = apply { + this.latencyColumnName = latencyColumnName + } + + /** Object with metadata. */ + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + /** Name of the column with the total number of tokens. */ + fun numOfTokenColumnName(numOfTokenColumnName: String?) = + numOfTokenColumnName(JsonField.ofNullable(numOfTokenColumnName)) + + /** + * Alias for calling [Builder.numOfTokenColumnName] with + * `numOfTokenColumnName.orElse(null)`. + */ + fun numOfTokenColumnName(numOfTokenColumnName: Optional) = + numOfTokenColumnName(numOfTokenColumnName.getOrNull()) + + /** + * Sets [Builder.numOfTokenColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.numOfTokenColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun numOfTokenColumnName(numOfTokenColumnName: JsonField) = apply { + this.numOfTokenColumnName = numOfTokenColumnName + } + + /** Prompt for the LLM. */ + fun prompt(prompt: List) = prompt(JsonField.of(prompt)) + + /** + * Sets [Builder.prompt] to an arbitrary JSON value. + * + * You should usually call [Builder.prompt] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prompt(prompt: JsonField>) = apply { + this.prompt = prompt.map { it.toMutableList() } + } + + /** + * Adds a single [Prompt] to [Builder.prompt]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPrompt(prompt: Prompt) = apply { + this.prompt = + (this.prompt ?: JsonField.of(mutableListOf())).also { + checkKnown("prompt", it).add(prompt) + } + } + + /** + * Name of the column with the questions. Applies to RAG use cases. Providing the + * question enables RAG-specific metrics. + */ + fun questionColumnName(questionColumnName: String) = + questionColumnName(JsonField.of(questionColumnName)) + + /** + * Sets [Builder.questionColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.questionColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun questionColumnName(questionColumnName: JsonField) = apply { + this.questionColumnName = questionColumnName + } + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If + * not provided, the upload timestamp is used. + */ + fun timestampColumnName(timestampColumnName: String) = + timestampColumnName(JsonField.of(timestampColumnName)) + + /** + * Sets [Builder.timestampColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.timestampColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun timestampColumnName(timestampColumnName: JsonField) = apply { + this.timestampColumnName = timestampColumnName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LlmData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .outputColumnName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LlmData = + LlmData( + checkRequired("outputColumnName", outputColumnName), + contextColumnName, + costColumnName, + groundTruthColumnName, + inferenceIdColumnName, + (inputVariableNames ?: JsonMissing.of()).map { it.toImmutable() }, + latencyColumnName, + metadata, + numOfTokenColumnName, + (prompt ?: JsonMissing.of()).map { it.toImmutable() }, + questionColumnName, + timestampColumnName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LlmData = apply { + if (validated) { + return@apply + } + + outputColumnName() + contextColumnName() + costColumnName() + groundTruthColumnName() + inferenceIdColumnName() + inputVariableNames() + latencyColumnName() + numOfTokenColumnName() + prompt().ifPresent { it.forEach { it.validate() } } + questionColumnName() + timestampColumnName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (outputColumnName.asKnown().isPresent) 1 else 0) + + (if (contextColumnName.asKnown().isPresent) 1 else 0) + + (if (costColumnName.asKnown().isPresent) 1 else 0) + + (if (groundTruthColumnName.asKnown().isPresent) 1 else 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (inputVariableNames.asKnown().getOrNull()?.size ?: 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (numOfTokenColumnName.asKnown().isPresent) 1 else 0) + + (prompt.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (questionColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + + class Prompt + 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()) + + /** + * Content of the prompt. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * Role of the prompt. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun role(): Optional = role.getOptional("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 [Prompt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Prompt]. */ + class Builder internal constructor() { + + private var content: JsonField = JsonMissing.of() + private var role: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(prompt: Prompt) = apply { + content = prompt.content + role = prompt.role + additionalProperties = prompt.additionalProperties.toMutableMap() + } + + /** Content of the prompt. */ + 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 } + + /** Role of the prompt. */ + fun role(role: String) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [String] 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 [Prompt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Prompt = Prompt(content, role, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Prompt = apply { + if (validated) { + return@apply + } + + content() + role() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + (if (role.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prompt && content == other.content && role == other.role && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(content, role, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Prompt{content=$content, role=$role, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is LlmData && outputColumnName == other.outputColumnName && contextColumnName == other.contextColumnName && costColumnName == other.costColumnName && groundTruthColumnName == other.groundTruthColumnName && inferenceIdColumnName == other.inferenceIdColumnName && inputVariableNames == other.inputVariableNames && latencyColumnName == other.latencyColumnName && metadata == other.metadata && numOfTokenColumnName == other.numOfTokenColumnName && prompt == other.prompt && questionColumnName == other.questionColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(outputColumnName, contextColumnName, costColumnName, groundTruthColumnName, inferenceIdColumnName, inputVariableNames, latencyColumnName, metadata, numOfTokenColumnName, prompt, questionColumnName, timestampColumnName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LlmData{outputColumnName=$outputColumnName, contextColumnName=$contextColumnName, costColumnName=$costColumnName, groundTruthColumnName=$groundTruthColumnName, inferenceIdColumnName=$inferenceIdColumnName, inputVariableNames=$inputVariableNames, latencyColumnName=$latencyColumnName, metadata=$metadata, numOfTokenColumnName=$numOfTokenColumnName, prompt=$prompt, questionColumnName=$questionColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" + } + + class TabularClassificationData + private constructor( + private val classNames: JsonField>, + private val categoricalFeatureNames: JsonField>, + private val featureNames: JsonField>, + private val inferenceIdColumnName: JsonField, + private val labelColumnName: JsonField, + private val latencyColumnName: JsonField, + private val metadata: JsonValue, + private val predictionsColumnName: JsonField, + private val predictionScoresColumnName: JsonField, + private val timestampColumnName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("classNames") + @ExcludeMissing + classNames: JsonField> = JsonMissing.of(), + @JsonProperty("categoricalFeatureNames") + @ExcludeMissing + categoricalFeatureNames: JsonField> = JsonMissing.of(), + @JsonProperty("featureNames") + @ExcludeMissing + featureNames: JsonField> = JsonMissing.of(), + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + inferenceIdColumnName: JsonField = JsonMissing.of(), + @JsonProperty("labelColumnName") + @ExcludeMissing + labelColumnName: JsonField = JsonMissing.of(), + @JsonProperty("latencyColumnName") + @ExcludeMissing + latencyColumnName: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("predictionsColumnName") + @ExcludeMissing + predictionsColumnName: JsonField = JsonMissing.of(), + @JsonProperty("predictionScoresColumnName") + @ExcludeMissing + predictionScoresColumnName: JsonField = JsonMissing.of(), + @JsonProperty("timestampColumnName") + @ExcludeMissing + timestampColumnName: JsonField = JsonMissing.of(), + ) : this( + classNames, + categoricalFeatureNames, + featureNames, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + timestampColumnName, + mutableMapOf(), + ) + + /** + * List of class names indexed by label integer in the dataset. E.g. + * ["Retained", "Exited"] when 0, 1 are in your label column. + * + * @throws OpenlayerInvalidDataException 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 classNames(): List = classNames.getRequired("classNames") + + /** + * Array with the names of all categorical features in the dataset. E.g. + * ["Age", "Geography"]. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun categoricalFeatureNames(): Optional> = + categoricalFeatureNames.getOptional("categoricalFeatureNames") + + /** + * Array with all input feature names. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun featureNames(): Optional> = featureNames.getOptional("featureNames") + + /** + * Name of the column with the inference ids. This is useful if you want to update rows + * at a later point in time. If not provided, a unique id is generated by Openlayer. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inferenceIdColumnName(): Optional = + inferenceIdColumnName.getOptional("inferenceIdColumnName") + + /** + * Name of the column with the labels. The data in this column must be **zero-indexed + * integers**, matching the list provided in `classNames`. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun labelColumnName(): Optional = labelColumnName.getOptional("labelColumnName") + + /** + * Name of the column with the latencies. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun latencyColumnName(): Optional = + latencyColumnName.getOptional("latencyColumnName") + + /** Object with metadata. */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * Name of the column with the model's predictions as **zero-indexed integers**. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionsColumnName(): Optional = + predictionsColumnName.getOptional("predictionsColumnName") + + /** + * Name of the column with the model's predictions as **lists of class probabilities**. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionScoresColumnName(): Optional = + predictionScoresColumnName.getOptional("predictionScoresColumnName") + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun timestampColumnName(): Optional = + timestampColumnName.getOptional("timestampColumnName") + + /** + * Returns the raw JSON value of [classNames]. + * + * Unlike [classNames], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("classNames") + @ExcludeMissing + fun _classNames(): JsonField> = classNames + + /** + * Returns the raw JSON value of [categoricalFeatureNames]. + * + * Unlike [categoricalFeatureNames], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("categoricalFeatureNames") + @ExcludeMissing + fun _categoricalFeatureNames(): JsonField> = categoricalFeatureNames + + /** + * Returns the raw JSON value of [featureNames]. + * + * Unlike [featureNames], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("featureNames") + @ExcludeMissing + fun _featureNames(): JsonField> = featureNames + + /** + * Returns the raw JSON value of [inferenceIdColumnName]. + * + * Unlike [inferenceIdColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + fun _inferenceIdColumnName(): JsonField = inferenceIdColumnName + + /** + * Returns the raw JSON value of [labelColumnName]. + * + * Unlike [labelColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("labelColumnName") + @ExcludeMissing + fun _labelColumnName(): JsonField = labelColumnName + + /** + * Returns the raw JSON value of [latencyColumnName]. + * + * Unlike [latencyColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("latencyColumnName") + @ExcludeMissing + fun _latencyColumnName(): JsonField = latencyColumnName + + /** + * Returns the raw JSON value of [predictionsColumnName]. + * + * Unlike [predictionsColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionsColumnName") + @ExcludeMissing + fun _predictionsColumnName(): JsonField = predictionsColumnName + + /** + * Returns the raw JSON value of [predictionScoresColumnName]. + * + * Unlike [predictionScoresColumnName], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("predictionScoresColumnName") + @ExcludeMissing + fun _predictionScoresColumnName(): JsonField = predictionScoresColumnName + + /** + * Returns the raw JSON value of [timestampColumnName]. + * + * Unlike [timestampColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("timestampColumnName") + @ExcludeMissing + fun _timestampColumnName(): JsonField = timestampColumnName + + @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 + * [TabularClassificationData]. + * + * The following fields are required: + * ```java + * .classNames() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TabularClassificationData]. */ + class Builder internal constructor() { + + private var classNames: JsonField>? = null + private var categoricalFeatureNames: JsonField>? = null + private var featureNames: JsonField>? = null + private var inferenceIdColumnName: JsonField = JsonMissing.of() + private var labelColumnName: JsonField = JsonMissing.of() + private var latencyColumnName: JsonField = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var predictionsColumnName: JsonField = JsonMissing.of() + private var predictionScoresColumnName: JsonField = JsonMissing.of() + private var timestampColumnName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tabularClassificationData: TabularClassificationData) = apply { + classNames = tabularClassificationData.classNames.map { it.toMutableList() } + categoricalFeatureNames = + tabularClassificationData.categoricalFeatureNames.map { it.toMutableList() } + featureNames = tabularClassificationData.featureNames.map { it.toMutableList() } + inferenceIdColumnName = tabularClassificationData.inferenceIdColumnName + labelColumnName = tabularClassificationData.labelColumnName + latencyColumnName = tabularClassificationData.latencyColumnName + metadata = tabularClassificationData.metadata + predictionsColumnName = tabularClassificationData.predictionsColumnName + predictionScoresColumnName = + tabularClassificationData.predictionScoresColumnName + timestampColumnName = tabularClassificationData.timestampColumnName + additionalProperties = + tabularClassificationData.additionalProperties.toMutableMap() + } + + /** + * List of class names indexed by label integer in the dataset. E.g. + * ["Retained", "Exited"] when 0, 1 are in your label column. + */ + fun classNames(classNames: List) = classNames(JsonField.of(classNames)) + + /** + * Sets [Builder.classNames] to an arbitrary JSON value. + * + * You should usually call [Builder.classNames] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun classNames(classNames: JsonField>) = apply { + this.classNames = classNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [classNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addClassName(className: String) = apply { + classNames = + (classNames ?: JsonField.of(mutableListOf())).also { + checkKnown("classNames", it).add(className) + } + } + + /** + * Array with the names of all categorical features in the dataset. E.g. + * ["Age", "Geography"]. + */ + fun categoricalFeatureNames(categoricalFeatureNames: List) = + categoricalFeatureNames(JsonField.of(categoricalFeatureNames)) + + /** + * Sets [Builder.categoricalFeatureNames] to an arbitrary JSON value. + * + * You should usually call [Builder.categoricalFeatureNames] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun categoricalFeatureNames(categoricalFeatureNames: JsonField>) = + apply { + this.categoricalFeatureNames = + categoricalFeatureNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [categoricalFeatureNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategoricalFeatureName(categoricalFeatureName: String) = apply { + categoricalFeatureNames = + (categoricalFeatureNames ?: JsonField.of(mutableListOf())).also { + checkKnown("categoricalFeatureNames", it).add(categoricalFeatureName) + } + } + + /** Array with all input feature names. */ + fun featureNames(featureNames: List) = + featureNames(JsonField.of(featureNames)) + + /** + * Sets [Builder.featureNames] to an arbitrary JSON value. + * + * You should usually call [Builder.featureNames] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun featureNames(featureNames: JsonField>) = apply { + this.featureNames = featureNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [featureNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFeatureName(featureName: String) = apply { + featureNames = + (featureNames ?: JsonField.of(mutableListOf())).also { + checkKnown("featureNames", it).add(featureName) + } + } + + /** + * Name of the column with the inference ids. This is useful if you want to update + * rows at a later point in time. If not provided, a unique id is generated by + * Openlayer. + */ + fun inferenceIdColumnName(inferenceIdColumnName: String) = + inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) + + /** + * Sets [Builder.inferenceIdColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.inferenceIdColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { + this.inferenceIdColumnName = inferenceIdColumnName + } + + /** + * Name of the column with the labels. The data in this column must be + * **zero-indexed integers**, matching the list provided in `classNames`. + */ + fun labelColumnName(labelColumnName: String) = + labelColumnName(JsonField.of(labelColumnName)) + + /** + * Sets [Builder.labelColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.labelColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun labelColumnName(labelColumnName: JsonField) = apply { + this.labelColumnName = labelColumnName + } + + /** Name of the column with the latencies. */ + fun latencyColumnName(latencyColumnName: String) = + latencyColumnName(JsonField.of(latencyColumnName)) + + /** + * Sets [Builder.latencyColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun latencyColumnName(latencyColumnName: JsonField) = apply { + this.latencyColumnName = latencyColumnName + } + + /** Object with metadata. */ + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + /** Name of the column with the model's predictions as **zero-indexed integers**. */ + fun predictionsColumnName(predictionsColumnName: String) = + predictionsColumnName(JsonField.of(predictionsColumnName)) + + /** + * Sets [Builder.predictionsColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionsColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictionsColumnName(predictionsColumnName: JsonField) = apply { + this.predictionsColumnName = predictionsColumnName + } + + /** + * Name of the column with the model's predictions as **lists of class + * probabilities**. + */ + fun predictionScoresColumnName(predictionScoresColumnName: String) = + predictionScoresColumnName(JsonField.of(predictionScoresColumnName)) + + /** + * Sets [Builder.predictionScoresColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionScoresColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictionScoresColumnName(predictionScoresColumnName: JsonField) = + apply { + this.predictionScoresColumnName = predictionScoresColumnName + } + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If + * not provided, the upload timestamp is used. + */ + fun timestampColumnName(timestampColumnName: String) = + timestampColumnName(JsonField.of(timestampColumnName)) + + /** + * Sets [Builder.timestampColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.timestampColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun timestampColumnName(timestampColumnName: JsonField) = apply { + this.timestampColumnName = timestampColumnName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TabularClassificationData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .classNames() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TabularClassificationData = + TabularClassificationData( + checkRequired("classNames", classNames).map { it.toImmutable() }, + (categoricalFeatureNames ?: JsonMissing.of()).map { it.toImmutable() }, + (featureNames ?: JsonMissing.of()).map { it.toImmutable() }, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + timestampColumnName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TabularClassificationData = apply { + if (validated) { + return@apply + } + + classNames() + categoricalFeatureNames() + featureNames() + inferenceIdColumnName() + labelColumnName() + latencyColumnName() + predictionsColumnName() + predictionScoresColumnName() + timestampColumnName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (classNames.asKnown().getOrNull()?.size ?: 0) + + (categoricalFeatureNames.asKnown().getOrNull()?.size ?: 0) + + (featureNames.asKnown().getOrNull()?.size ?: 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (labelColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionsColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionScoresColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TabularClassificationData && classNames == other.classNames && categoricalFeatureNames == other.categoricalFeatureNames && featureNames == other.featureNames && inferenceIdColumnName == other.inferenceIdColumnName && labelColumnName == other.labelColumnName && latencyColumnName == other.latencyColumnName && metadata == other.metadata && predictionsColumnName == other.predictionsColumnName && predictionScoresColumnName == other.predictionScoresColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(classNames, categoricalFeatureNames, featureNames, inferenceIdColumnName, labelColumnName, latencyColumnName, metadata, predictionsColumnName, predictionScoresColumnName, timestampColumnName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TabularClassificationData{classNames=$classNames, categoricalFeatureNames=$categoricalFeatureNames, featureNames=$featureNames, inferenceIdColumnName=$inferenceIdColumnName, labelColumnName=$labelColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, predictionScoresColumnName=$predictionScoresColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" + } + + class TabularRegressionData + private constructor( + private val categoricalFeatureNames: JsonField>, + private val featureNames: JsonField>, + private val inferenceIdColumnName: JsonField, + private val latencyColumnName: JsonField, + private val metadata: JsonValue, + private val predictionsColumnName: JsonField, + private val targetColumnName: JsonField, + private val timestampColumnName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("categoricalFeatureNames") + @ExcludeMissing + categoricalFeatureNames: JsonField> = JsonMissing.of(), + @JsonProperty("featureNames") + @ExcludeMissing + featureNames: JsonField> = JsonMissing.of(), + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + inferenceIdColumnName: JsonField = JsonMissing.of(), + @JsonProperty("latencyColumnName") + @ExcludeMissing + latencyColumnName: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("predictionsColumnName") + @ExcludeMissing + predictionsColumnName: JsonField = JsonMissing.of(), + @JsonProperty("targetColumnName") + @ExcludeMissing + targetColumnName: JsonField = JsonMissing.of(), + @JsonProperty("timestampColumnName") + @ExcludeMissing + timestampColumnName: JsonField = JsonMissing.of(), + ) : this( + categoricalFeatureNames, + featureNames, + inferenceIdColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + targetColumnName, + timestampColumnName, + mutableMapOf(), + ) + + /** + * Array with the names of all categorical features in the dataset. E.g. + * ["Gender", "Geography"]. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun categoricalFeatureNames(): Optional> = + categoricalFeatureNames.getOptional("categoricalFeatureNames") + + /** + * Array with all input feature names. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun featureNames(): Optional> = featureNames.getOptional("featureNames") + + /** + * Name of the column with the inference ids. This is useful if you want to update rows + * at a later point in time. If not provided, a unique id is generated by Openlayer. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inferenceIdColumnName(): Optional = + inferenceIdColumnName.getOptional("inferenceIdColumnName") + + /** + * Name of the column with the latencies. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun latencyColumnName(): Optional = + latencyColumnName.getOptional("latencyColumnName") + + /** Object with metadata. */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * Name of the column with the model's predictions. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionsColumnName(): Optional = + predictionsColumnName.getOptional("predictionsColumnName") + + /** + * Name of the column with the targets (ground truth values). + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun targetColumnName(): Optional = + targetColumnName.getOptional("targetColumnName") + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun timestampColumnName(): Optional = + timestampColumnName.getOptional("timestampColumnName") + + /** + * Returns the raw JSON value of [categoricalFeatureNames]. + * + * Unlike [categoricalFeatureNames], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("categoricalFeatureNames") + @ExcludeMissing + fun _categoricalFeatureNames(): JsonField> = categoricalFeatureNames + + /** + * Returns the raw JSON value of [featureNames]. + * + * Unlike [featureNames], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("featureNames") + @ExcludeMissing + fun _featureNames(): JsonField> = featureNames + + /** + * Returns the raw JSON value of [inferenceIdColumnName]. + * + * Unlike [inferenceIdColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + fun _inferenceIdColumnName(): JsonField = inferenceIdColumnName + + /** + * Returns the raw JSON value of [latencyColumnName]. + * + * Unlike [latencyColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("latencyColumnName") + @ExcludeMissing + fun _latencyColumnName(): JsonField = latencyColumnName + + /** + * Returns the raw JSON value of [predictionsColumnName]. + * + * Unlike [predictionsColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionsColumnName") + @ExcludeMissing + fun _predictionsColumnName(): JsonField = predictionsColumnName + + /** + * Returns the raw JSON value of [targetColumnName]. + * + * Unlike [targetColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("targetColumnName") + @ExcludeMissing + fun _targetColumnName(): JsonField = targetColumnName + + /** + * Returns the raw JSON value of [timestampColumnName]. + * + * Unlike [timestampColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("timestampColumnName") + @ExcludeMissing + fun _timestampColumnName(): JsonField = timestampColumnName + + @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 + * [TabularRegressionData]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TabularRegressionData]. */ + class Builder internal constructor() { + + private var categoricalFeatureNames: JsonField>? = null + private var featureNames: JsonField>? = null + private var inferenceIdColumnName: JsonField = JsonMissing.of() + private var latencyColumnName: JsonField = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var predictionsColumnName: JsonField = JsonMissing.of() + private var targetColumnName: JsonField = JsonMissing.of() + private var timestampColumnName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tabularRegressionData: TabularRegressionData) = apply { + categoricalFeatureNames = + tabularRegressionData.categoricalFeatureNames.map { it.toMutableList() } + featureNames = tabularRegressionData.featureNames.map { it.toMutableList() } + inferenceIdColumnName = tabularRegressionData.inferenceIdColumnName + latencyColumnName = tabularRegressionData.latencyColumnName + metadata = tabularRegressionData.metadata + predictionsColumnName = tabularRegressionData.predictionsColumnName + targetColumnName = tabularRegressionData.targetColumnName + timestampColumnName = tabularRegressionData.timestampColumnName + additionalProperties = tabularRegressionData.additionalProperties.toMutableMap() + } + + /** + * Array with the names of all categorical features in the dataset. E.g. + * ["Gender", "Geography"]. + */ + fun categoricalFeatureNames(categoricalFeatureNames: List) = + categoricalFeatureNames(JsonField.of(categoricalFeatureNames)) + + /** + * Sets [Builder.categoricalFeatureNames] to an arbitrary JSON value. + * + * You should usually call [Builder.categoricalFeatureNames] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun categoricalFeatureNames(categoricalFeatureNames: JsonField>) = + apply { + this.categoricalFeatureNames = + categoricalFeatureNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [categoricalFeatureNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategoricalFeatureName(categoricalFeatureName: String) = apply { + categoricalFeatureNames = + (categoricalFeatureNames ?: JsonField.of(mutableListOf())).also { + checkKnown("categoricalFeatureNames", it).add(categoricalFeatureName) + } + } + + /** Array with all input feature names. */ + fun featureNames(featureNames: List) = + featureNames(JsonField.of(featureNames)) + + /** + * Sets [Builder.featureNames] to an arbitrary JSON value. + * + * You should usually call [Builder.featureNames] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun featureNames(featureNames: JsonField>) = apply { + this.featureNames = featureNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [featureNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFeatureName(featureName: String) = apply { + featureNames = + (featureNames ?: JsonField.of(mutableListOf())).also { + checkKnown("featureNames", it).add(featureName) + } + } + + /** + * Name of the column with the inference ids. This is useful if you want to update + * rows at a later point in time. If not provided, a unique id is generated by + * Openlayer. + */ + fun inferenceIdColumnName(inferenceIdColumnName: String) = + inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) + + /** + * Sets [Builder.inferenceIdColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.inferenceIdColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { + this.inferenceIdColumnName = inferenceIdColumnName + } + + /** Name of the column with the latencies. */ + fun latencyColumnName(latencyColumnName: String) = + latencyColumnName(JsonField.of(latencyColumnName)) + + /** + * Sets [Builder.latencyColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun latencyColumnName(latencyColumnName: JsonField) = apply { + this.latencyColumnName = latencyColumnName + } + + /** Object with metadata. */ + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + /** Name of the column with the model's predictions. */ + fun predictionsColumnName(predictionsColumnName: String) = + predictionsColumnName(JsonField.of(predictionsColumnName)) + + /** + * Sets [Builder.predictionsColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionsColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictionsColumnName(predictionsColumnName: JsonField) = apply { + this.predictionsColumnName = predictionsColumnName + } + + /** Name of the column with the targets (ground truth values). */ + fun targetColumnName(targetColumnName: String) = + targetColumnName(JsonField.of(targetColumnName)) + + /** + * Sets [Builder.targetColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.targetColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun targetColumnName(targetColumnName: JsonField) = apply { + this.targetColumnName = targetColumnName + } + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If + * not provided, the upload timestamp is used. + */ + fun timestampColumnName(timestampColumnName: String) = + timestampColumnName(JsonField.of(timestampColumnName)) + + /** + * Sets [Builder.timestampColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.timestampColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun timestampColumnName(timestampColumnName: JsonField) = apply { + this.timestampColumnName = timestampColumnName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TabularRegressionData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TabularRegressionData = + TabularRegressionData( + (categoricalFeatureNames ?: JsonMissing.of()).map { it.toImmutable() }, + (featureNames ?: JsonMissing.of()).map { it.toImmutable() }, + inferenceIdColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + targetColumnName, + timestampColumnName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TabularRegressionData = apply { + if (validated) { + return@apply + } + + categoricalFeatureNames() + featureNames() + inferenceIdColumnName() + latencyColumnName() + predictionsColumnName() + targetColumnName() + timestampColumnName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (categoricalFeatureNames.asKnown().getOrNull()?.size ?: 0) + + (featureNames.asKnown().getOrNull()?.size ?: 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionsColumnName.asKnown().isPresent) 1 else 0) + + (if (targetColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TabularRegressionData && categoricalFeatureNames == other.categoricalFeatureNames && featureNames == other.featureNames && inferenceIdColumnName == other.inferenceIdColumnName && latencyColumnName == other.latencyColumnName && metadata == other.metadata && predictionsColumnName == other.predictionsColumnName && targetColumnName == other.targetColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(categoricalFeatureNames, featureNames, inferenceIdColumnName, latencyColumnName, metadata, predictionsColumnName, targetColumnName, timestampColumnName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TabularRegressionData{categoricalFeatureNames=$categoricalFeatureNames, featureNames=$featureNames, inferenceIdColumnName=$inferenceIdColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, targetColumnName=$targetColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" + } + + class TextClassificationData + private constructor( + private val classNames: JsonField>, + private val inferenceIdColumnName: JsonField, + private val labelColumnName: JsonField, + private val latencyColumnName: JsonField, + private val metadata: JsonValue, + private val predictionsColumnName: JsonField, + private val predictionScoresColumnName: JsonField, + private val textColumnName: JsonField, + private val timestampColumnName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("classNames") + @ExcludeMissing + classNames: JsonField> = JsonMissing.of(), + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + inferenceIdColumnName: JsonField = JsonMissing.of(), + @JsonProperty("labelColumnName") + @ExcludeMissing + labelColumnName: JsonField = JsonMissing.of(), + @JsonProperty("latencyColumnName") + @ExcludeMissing + latencyColumnName: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonValue = JsonMissing.of(), + @JsonProperty("predictionsColumnName") + @ExcludeMissing + predictionsColumnName: JsonField = JsonMissing.of(), + @JsonProperty("predictionScoresColumnName") + @ExcludeMissing + predictionScoresColumnName: JsonField = JsonMissing.of(), + @JsonProperty("textColumnName") + @ExcludeMissing + textColumnName: JsonField = JsonMissing.of(), + @JsonProperty("timestampColumnName") + @ExcludeMissing + timestampColumnName: JsonField = JsonMissing.of(), + ) : this( + classNames, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + textColumnName, + timestampColumnName, + mutableMapOf(), + ) + + /** + * List of class names indexed by label integer in the dataset. E.g. + * ["Retained", "Exited"] when 0, 1 are in your label column. + * + * @throws OpenlayerInvalidDataException 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 classNames(): List = classNames.getRequired("classNames") + + /** + * Name of the column with the inference ids. This is useful if you want to update rows + * at a later point in time. If not provided, a unique id is generated by Openlayer. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inferenceIdColumnName(): Optional = + inferenceIdColumnName.getOptional("inferenceIdColumnName") + + /** + * Name of the column with the labels. The data in this column must be **zero-indexed + * integers**, matching the list provided in `classNames`. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun labelColumnName(): Optional = labelColumnName.getOptional("labelColumnName") + + /** + * Name of the column with the latencies. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun latencyColumnName(): Optional = + latencyColumnName.getOptional("latencyColumnName") + + /** Object with metadata. */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonValue = metadata + + /** + * Name of the column with the model's predictions as **zero-indexed integers**. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionsColumnName(): Optional = + predictionsColumnName.getOptional("predictionsColumnName") + + /** + * Name of the column with the model's predictions as **lists of class probabilities**. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionScoresColumnName(): Optional = + predictionScoresColumnName.getOptional("predictionScoresColumnName") + + /** + * Name of the column with the text data. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun textColumnName(): Optional = textColumnName.getOptional("textColumnName") + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun timestampColumnName(): Optional = + timestampColumnName.getOptional("timestampColumnName") + + /** + * Returns the raw JSON value of [classNames]. + * + * Unlike [classNames], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("classNames") + @ExcludeMissing + fun _classNames(): JsonField> = classNames + + /** + * Returns the raw JSON value of [inferenceIdColumnName]. + * + * Unlike [inferenceIdColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + fun _inferenceIdColumnName(): JsonField = inferenceIdColumnName + + /** + * Returns the raw JSON value of [labelColumnName]. + * + * Unlike [labelColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("labelColumnName") + @ExcludeMissing + fun _labelColumnName(): JsonField = labelColumnName + + /** + * Returns the raw JSON value of [latencyColumnName]. + * + * Unlike [latencyColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("latencyColumnName") + @ExcludeMissing + fun _latencyColumnName(): JsonField = latencyColumnName + + /** + * Returns the raw JSON value of [predictionsColumnName]. + * + * Unlike [predictionsColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionsColumnName") + @ExcludeMissing + fun _predictionsColumnName(): JsonField = predictionsColumnName + + /** + * Returns the raw JSON value of [predictionScoresColumnName]. + * + * Unlike [predictionScoresColumnName], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("predictionScoresColumnName") + @ExcludeMissing + fun _predictionScoresColumnName(): JsonField = predictionScoresColumnName + + /** + * Returns the raw JSON value of [textColumnName]. + * + * Unlike [textColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("textColumnName") + @ExcludeMissing + fun _textColumnName(): JsonField = textColumnName + + /** + * Returns the raw JSON value of [timestampColumnName]. + * + * Unlike [timestampColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("timestampColumnName") + @ExcludeMissing + fun _timestampColumnName(): JsonField = timestampColumnName + + @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 + * [TextClassificationData]. + * + * The following fields are required: + * ```java + * .classNames() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TextClassificationData]. */ + class Builder internal constructor() { + + private var classNames: JsonField>? = null + private var inferenceIdColumnName: JsonField = JsonMissing.of() + private var labelColumnName: JsonField = JsonMissing.of() + private var latencyColumnName: JsonField = JsonMissing.of() + private var metadata: JsonValue = JsonMissing.of() + private var predictionsColumnName: JsonField = JsonMissing.of() + private var predictionScoresColumnName: JsonField = JsonMissing.of() + private var textColumnName: JsonField = JsonMissing.of() + private var timestampColumnName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(textClassificationData: TextClassificationData) = apply { + classNames = textClassificationData.classNames.map { it.toMutableList() } + inferenceIdColumnName = textClassificationData.inferenceIdColumnName + labelColumnName = textClassificationData.labelColumnName + latencyColumnName = textClassificationData.latencyColumnName + metadata = textClassificationData.metadata + predictionsColumnName = textClassificationData.predictionsColumnName + predictionScoresColumnName = textClassificationData.predictionScoresColumnName + textColumnName = textClassificationData.textColumnName + timestampColumnName = textClassificationData.timestampColumnName + additionalProperties = + textClassificationData.additionalProperties.toMutableMap() + } + + /** + * List of class names indexed by label integer in the dataset. E.g. + * ["Retained", "Exited"] when 0, 1 are in your label column. + */ + fun classNames(classNames: List) = classNames(JsonField.of(classNames)) + + /** + * Sets [Builder.classNames] to an arbitrary JSON value. + * + * You should usually call [Builder.classNames] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun classNames(classNames: JsonField>) = apply { + this.classNames = classNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [classNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addClassName(className: String) = apply { + classNames = + (classNames ?: JsonField.of(mutableListOf())).also { + checkKnown("classNames", it).add(className) + } + } + + /** + * Name of the column with the inference ids. This is useful if you want to update + * rows at a later point in time. If not provided, a unique id is generated by + * Openlayer. + */ + fun inferenceIdColumnName(inferenceIdColumnName: String) = + inferenceIdColumnName(JsonField.of(inferenceIdColumnName)) + + /** + * Sets [Builder.inferenceIdColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.inferenceIdColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { + this.inferenceIdColumnName = inferenceIdColumnName + } + + /** + * Name of the column with the labels. The data in this column must be + * **zero-indexed integers**, matching the list provided in `classNames`. + */ + fun labelColumnName(labelColumnName: String) = + labelColumnName(JsonField.of(labelColumnName)) + + /** + * Sets [Builder.labelColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.labelColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun labelColumnName(labelColumnName: JsonField) = apply { + this.labelColumnName = labelColumnName + } + + /** Name of the column with the latencies. */ + fun latencyColumnName(latencyColumnName: String) = + latencyColumnName(JsonField.of(latencyColumnName)) + + /** + * Sets [Builder.latencyColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun latencyColumnName(latencyColumnName: JsonField) = apply { + this.latencyColumnName = latencyColumnName + } + + /** Object with metadata. */ + fun metadata(metadata: JsonValue) = apply { this.metadata = metadata } + + /** Name of the column with the model's predictions as **zero-indexed integers**. */ + fun predictionsColumnName(predictionsColumnName: String) = + predictionsColumnName(JsonField.of(predictionsColumnName)) + + /** + * Sets [Builder.predictionsColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionsColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictionsColumnName(predictionsColumnName: JsonField) = apply { + this.predictionsColumnName = predictionsColumnName + } + + /** + * Name of the column with the model's predictions as **lists of class + * probabilities**. + */ + fun predictionScoresColumnName(predictionScoresColumnName: String) = + predictionScoresColumnName(JsonField.of(predictionScoresColumnName)) + + /** + * Sets [Builder.predictionScoresColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionScoresColumnName] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictionScoresColumnName(predictionScoresColumnName: JsonField) = + apply { + this.predictionScoresColumnName = predictionScoresColumnName + } + + /** Name of the column with the text data. */ + fun textColumnName(textColumnName: String) = + textColumnName(JsonField.of(textColumnName)) + + /** + * Sets [Builder.textColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.textColumnName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun textColumnName(textColumnName: JsonField) = apply { + this.textColumnName = textColumnName + } + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If + * not provided, the upload timestamp is used. + */ + fun timestampColumnName(timestampColumnName: String) = + timestampColumnName(JsonField.of(timestampColumnName)) + + /** + * Sets [Builder.timestampColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.timestampColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun timestampColumnName(timestampColumnName: JsonField) = apply { + this.timestampColumnName = timestampColumnName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TextClassificationData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .classNames() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TextClassificationData = + TextClassificationData( + checkRequired("classNames", classNames).map { it.toImmutable() }, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + textColumnName, + timestampColumnName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TextClassificationData = apply { + if (validated) { + return@apply + } + + classNames() + inferenceIdColumnName() + labelColumnName() + latencyColumnName() + predictionsColumnName() + predictionScoresColumnName() + textColumnName() + timestampColumnName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (classNames.asKnown().getOrNull()?.size ?: 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (labelColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionsColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionScoresColumnName.asKnown().isPresent) 1 else 0) + + (if (textColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TextClassificationData && classNames == other.classNames && inferenceIdColumnName == other.inferenceIdColumnName && labelColumnName == other.labelColumnName && latencyColumnName == other.latencyColumnName && metadata == other.metadata && predictionsColumnName == other.predictionsColumnName && predictionScoresColumnName == other.predictionScoresColumnName && textColumnName == other.textColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(classNames, inferenceIdColumnName, labelColumnName, latencyColumnName, metadata, predictionsColumnName, predictionScoresColumnName, textColumnName, timestampColumnName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TextClassificationData{classNames=$classNames, inferenceIdColumnName=$inferenceIdColumnName, labelColumnName=$labelColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, predictionScoresColumnName=$predictionScoresColumnName, textColumnName=$textColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" + } + } + + class Row + @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 [Row]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Row]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(row: Row) = apply { + additionalProperties = row.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 [Row]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Row = Row(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Row = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Row && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Row{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DataStreamParams && inferencePipelineId == other.inferencePipelineId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "DataStreamParams{inferencePipelineId=$inferencePipelineId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt new file mode 100644 index 00000000..0c4e4c11 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.data + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class DataStreamResponse +private constructor( + private val success: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("success") @ExcludeMissing success: JsonField = JsonMissing.of() + ) : this(success, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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(): Success = success.getRequired("success") + + /** + * 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 + + @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 [DataStreamResponse]. + * + * The following fields are required: + * ```java + * .success() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataStreamResponse]. */ + class Builder internal constructor() { + + private var success: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dataStreamResponse: DataStreamResponse) = apply { + success = dataStreamResponse.success + additionalProperties = dataStreamResponse.additionalProperties.toMutableMap() + } + + fun success(success: Success) = success(JsonField.of(success)) + + /** + * Sets [Builder.success] to an arbitrary JSON value. + * + * You should usually call [Builder.success] with a well-typed [Success] 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 } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DataStreamResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .success() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DataStreamResponse = + DataStreamResponse( + checkRequired("success", success), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DataStreamResponse = apply { + if (validated) { + return@apply + } + + success().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (success.asKnown().getOrNull()?.validity() ?: 0) + + class Success @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 TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = Success(JsonField.of(value)) + } + + /** An enum containing [Success]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [Success]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Success] 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 { + TRUE, + /** An enum member indicating that [Success] 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) { + TRUE -> Value.TRUE + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw OpenlayerInvalidDataException("Unknown Success: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + OpenlayerInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): Success = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Success && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DataStreamResponse && success == other.success && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DataStreamResponse{success=$success, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt new file mode 100644 index 00000000..93e28ac6 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt @@ -0,0 +1,836 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +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.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update an inference data point in an inference pipeline. */ +class RowUpdateParams +private constructor( + private val inferencePipelineId: String, + private val inferenceId: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun inferencePipelineId(): String = inferencePipelineId + + /** Specify the inference id as a query param. */ + fun inferenceId(): String = inferenceId + + fun _row(): JsonValue = body._row() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun config(): Optional = body.config() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RowUpdateParams]. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * .inferenceId() + * .row() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RowUpdateParams]. */ + class Builder internal constructor() { + + private var inferencePipelineId: String? = null + private var inferenceId: 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(rowUpdateParams: RowUpdateParams) = apply { + inferencePipelineId = rowUpdateParams.inferencePipelineId + inferenceId = rowUpdateParams.inferenceId + body = rowUpdateParams.body.toBuilder() + additionalHeaders = rowUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = rowUpdateParams.additionalQueryParams.toBuilder() + } + + fun inferencePipelineId(inferencePipelineId: String) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** Specify the inference id as a query param. */ + fun inferenceId(inferenceId: String) = apply { this.inferenceId = inferenceId } + + /** + * 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: + * - [row] + * - [config] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun row(row: JsonValue) = apply { body.row(row) } + + fun config(config: Config?) = apply { body.config(config) } + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { body.config(config) } + + fun 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 [RowUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * .inferenceId() + * .row() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RowUpdateParams = + RowUpdateParams( + checkRequired("inferencePipelineId", inferencePipelineId), + checkRequired("inferenceId", inferenceId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("inferenceId", inferenceId) + putAll(additionalQueryParams) + } + .build() + + class Body + private constructor( + private val row: JsonValue, + private val config: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("row") @ExcludeMissing row: JsonValue = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), + ) : this(row, config, mutableMapOf()) + + @JsonProperty("row") @ExcludeMissing fun _row(): JsonValue = row + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + @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 + * .row() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var row: JsonValue? = null + private var config: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + row = body.row + config = body.config + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun row(row: JsonValue) = apply { this.row = row } + + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .row() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("row", row), config, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + config().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (config.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && row == other.row && config == other.config && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(row, config, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{row=$row, config=$config, additionalProperties=$additionalProperties}" + } + + class Config + private constructor( + private val groundTruthColumnName: JsonField, + private val humanFeedbackColumnName: JsonField, + private val inferenceIdColumnName: JsonField, + private val latencyColumnName: JsonField, + private val timestampColumnName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("groundTruthColumnName") + @ExcludeMissing + groundTruthColumnName: JsonField = JsonMissing.of(), + @JsonProperty("humanFeedbackColumnName") + @ExcludeMissing + humanFeedbackColumnName: JsonField = JsonMissing.of(), + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + inferenceIdColumnName: JsonField = JsonMissing.of(), + @JsonProperty("latencyColumnName") + @ExcludeMissing + latencyColumnName: JsonField = JsonMissing.of(), + @JsonProperty("timestampColumnName") + @ExcludeMissing + timestampColumnName: JsonField = JsonMissing.of(), + ) : this( + groundTruthColumnName, + humanFeedbackColumnName, + inferenceIdColumnName, + latencyColumnName, + timestampColumnName, + mutableMapOf(), + ) + + /** + * Name of the column with the ground truths. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun groundTruthColumnName(): Optional = + groundTruthColumnName.getOptional("groundTruthColumnName") + + /** + * Name of the column with human feedback. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun humanFeedbackColumnName(): Optional = + humanFeedbackColumnName.getOptional("humanFeedbackColumnName") + + /** + * Name of the column with the inference ids. This is useful if you want to update rows at a + * later point in time. If not provided, a unique id is generated by Openlayer. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inferenceIdColumnName(): Optional = + inferenceIdColumnName.getOptional("inferenceIdColumnName") + + /** + * Name of the column with the latencies. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun latencyColumnName(): Optional = + latencyColumnName.getOptional("latencyColumnName") + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timestampColumnName(): Optional = + timestampColumnName.getOptional("timestampColumnName") + + /** + * Returns the raw JSON value of [groundTruthColumnName]. + * + * Unlike [groundTruthColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("groundTruthColumnName") + @ExcludeMissing + fun _groundTruthColumnName(): JsonField = groundTruthColumnName + + /** + * Returns the raw JSON value of [humanFeedbackColumnName]. + * + * Unlike [humanFeedbackColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("humanFeedbackColumnName") + @ExcludeMissing + fun _humanFeedbackColumnName(): JsonField = humanFeedbackColumnName + + /** + * Returns the raw JSON value of [inferenceIdColumnName]. + * + * Unlike [inferenceIdColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferenceIdColumnName") + @ExcludeMissing + fun _inferenceIdColumnName(): JsonField = inferenceIdColumnName + + /** + * Returns the raw JSON value of [latencyColumnName]. + * + * Unlike [latencyColumnName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("latencyColumnName") + @ExcludeMissing + fun _latencyColumnName(): JsonField = latencyColumnName + + /** + * Returns the raw JSON value of [timestampColumnName]. + * + * Unlike [timestampColumnName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("timestampColumnName") + @ExcludeMissing + fun _timestampColumnName(): JsonField = timestampColumnName + + @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 [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var groundTruthColumnName: JsonField = JsonMissing.of() + private var humanFeedbackColumnName: JsonField = JsonMissing.of() + private var inferenceIdColumnName: JsonField = JsonMissing.of() + private var latencyColumnName: JsonField = JsonMissing.of() + private var timestampColumnName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + groundTruthColumnName = config.groundTruthColumnName + humanFeedbackColumnName = config.humanFeedbackColumnName + inferenceIdColumnName = config.inferenceIdColumnName + latencyColumnName = config.latencyColumnName + timestampColumnName = config.timestampColumnName + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** Name of the column with the ground truths. */ + fun groundTruthColumnName(groundTruthColumnName: String?) = + groundTruthColumnName(JsonField.ofNullable(groundTruthColumnName)) + + /** + * Alias for calling [Builder.groundTruthColumnName] with + * `groundTruthColumnName.orElse(null)`. + */ + fun groundTruthColumnName(groundTruthColumnName: Optional) = + groundTruthColumnName(groundTruthColumnName.getOrNull()) + + /** + * Sets [Builder.groundTruthColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.groundTruthColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun groundTruthColumnName(groundTruthColumnName: JsonField) = apply { + this.groundTruthColumnName = groundTruthColumnName + } + + /** Name of the column with human feedback. */ + fun humanFeedbackColumnName(humanFeedbackColumnName: String?) = + humanFeedbackColumnName(JsonField.ofNullable(humanFeedbackColumnName)) + + /** + * Alias for calling [Builder.humanFeedbackColumnName] with + * `humanFeedbackColumnName.orElse(null)`. + */ + fun humanFeedbackColumnName(humanFeedbackColumnName: Optional) = + humanFeedbackColumnName(humanFeedbackColumnName.getOrNull()) + + /** + * Sets [Builder.humanFeedbackColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.humanFeedbackColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun humanFeedbackColumnName(humanFeedbackColumnName: JsonField) = apply { + this.humanFeedbackColumnName = humanFeedbackColumnName + } + + /** + * Name of the column with the inference ids. This is useful if you want to update rows + * at a later point in time. If not provided, a unique id is generated by Openlayer. + */ + fun inferenceIdColumnName(inferenceIdColumnName: String?) = + inferenceIdColumnName(JsonField.ofNullable(inferenceIdColumnName)) + + /** + * Alias for calling [Builder.inferenceIdColumnName] with + * `inferenceIdColumnName.orElse(null)`. + */ + fun inferenceIdColumnName(inferenceIdColumnName: Optional) = + inferenceIdColumnName(inferenceIdColumnName.getOrNull()) + + /** + * Sets [Builder.inferenceIdColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.inferenceIdColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferenceIdColumnName(inferenceIdColumnName: JsonField) = apply { + this.inferenceIdColumnName = inferenceIdColumnName + } + + /** Name of the column with the latencies. */ + fun latencyColumnName(latencyColumnName: String?) = + latencyColumnName(JsonField.ofNullable(latencyColumnName)) + + /** + * Alias for calling [Builder.latencyColumnName] with `latencyColumnName.orElse(null)`. + */ + fun latencyColumnName(latencyColumnName: Optional) = + latencyColumnName(latencyColumnName.getOrNull()) + + /** + * Sets [Builder.latencyColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.latencyColumnName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latencyColumnName(latencyColumnName: JsonField) = apply { + this.latencyColumnName = latencyColumnName + } + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + */ + fun timestampColumnName(timestampColumnName: String?) = + timestampColumnName(JsonField.ofNullable(timestampColumnName)) + + /** + * Alias for calling [Builder.timestampColumnName] with + * `timestampColumnName.orElse(null)`. + */ + fun timestampColumnName(timestampColumnName: Optional) = + timestampColumnName(timestampColumnName.getOrNull()) + + /** + * Sets [Builder.timestampColumnName] to an arbitrary JSON value. + * + * You should usually call [Builder.timestampColumnName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timestampColumnName(timestampColumnName: JsonField) = apply { + this.timestampColumnName = timestampColumnName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = + Config( + groundTruthColumnName, + humanFeedbackColumnName, + inferenceIdColumnName, + latencyColumnName, + timestampColumnName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + groundTruthColumnName() + humanFeedbackColumnName() + inferenceIdColumnName() + latencyColumnName() + timestampColumnName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (groundTruthColumnName.asKnown().isPresent) 1 else 0) + + (if (humanFeedbackColumnName.asKnown().isPresent) 1 else 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Config && groundTruthColumnName == other.groundTruthColumnName && humanFeedbackColumnName == other.humanFeedbackColumnName && inferenceIdColumnName == other.inferenceIdColumnName && latencyColumnName == other.latencyColumnName && timestampColumnName == other.timestampColumnName && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(groundTruthColumnName, humanFeedbackColumnName, inferenceIdColumnName, latencyColumnName, timestampColumnName, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Config{groundTruthColumnName=$groundTruthColumnName, humanFeedbackColumnName=$humanFeedbackColumnName, inferenceIdColumnName=$inferenceIdColumnName, latencyColumnName=$latencyColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RowUpdateParams && inferencePipelineId == other.inferencePipelineId && inferenceId == other.inferenceId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, inferenceId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "RowUpdateParams{inferencePipelineId=$inferencePipelineId, inferenceId=$inferenceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt new file mode 100644 index 00000000..74ed1e2b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class RowUpdateResponse +private constructor( + private val success: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("success") @ExcludeMissing success: JsonField = JsonMissing.of() + ) : this(success, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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(): Success = success.getRequired("success") + + /** + * 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 + + @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 [RowUpdateResponse]. + * + * The following fields are required: + * ```java + * .success() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RowUpdateResponse]. */ + class Builder internal constructor() { + + private var success: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rowUpdateResponse: RowUpdateResponse) = apply { + success = rowUpdateResponse.success + additionalProperties = rowUpdateResponse.additionalProperties.toMutableMap() + } + + fun success(success: Success) = success(JsonField.of(success)) + + /** + * Sets [Builder.success] to an arbitrary JSON value. + * + * You should usually call [Builder.success] with a well-typed [Success] 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 } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RowUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .success() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RowUpdateResponse = + RowUpdateResponse( + checkRequired("success", success), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RowUpdateResponse = apply { + if (validated) { + return@apply + } + + success().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (success.asKnown().getOrNull()?.validity() ?: 0) + + class Success @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 TRUE = of(true) + + @JvmStatic fun of(value: Boolean) = Success(JsonField.of(value)) + } + + /** An enum containing [Success]'s known values. */ + enum class Known { + TRUE + } + + /** + * An enum containing [Success]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Success] 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 { + TRUE, + /** An enum member indicating that [Success] 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) { + TRUE -> Value.TRUE + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw OpenlayerInvalidDataException("Unknown Success: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asBoolean(): Boolean = + _value().asBoolean().orElseThrow { + OpenlayerInvalidDataException("Value is not a Boolean") + } + + private var validated: Boolean = false + + fun validate(): Success = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Success && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RowUpdateResponse && success == other.success && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(success, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RowUpdateResponse{success=$success, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt new file mode 100644 index 00000000..b94b1557 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt @@ -0,0 +1,589 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.testresults + +import com.fasterxml.jackson.annotation.JsonCreator +import com.openlayer.api.core.Enum +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List the latest test results for an inference pipeline. */ +class TestResultListParams +private constructor( + private val inferencePipelineId: String, + private val page: Long?, + private val perPage: Long?, + private val status: Status?, + private val type: Type?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun inferencePipelineId(): String = inferencePipelineId + + /** The page to return in a paginated query. */ + fun page(): Optional = Optional.ofNullable(page) + + /** Maximum number of items to return per page. */ + fun perPage(): Optional = Optional.ofNullable(perPage) + + /** + * Filter list of test results by status. Available statuses are `running`, `passing`, + * `failing`, `skipped`, and `error`. + */ + fun status(): Optional = Optional.ofNullable(status) + + /** + * Filter objects by test type. Available types are `integrity`, `consistency`, `performance`, + * `fairness`, and `robustness`. + */ + fun type(): Optional = Optional.ofNullable(type) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TestResultListParams]. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TestResultListParams]. */ + class Builder internal constructor() { + + private var inferencePipelineId: String? = null + private var page: Long? = null + private var perPage: Long? = null + private var status: Status? = null + private var type: Type? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(testResultListParams: TestResultListParams) = apply { + inferencePipelineId = testResultListParams.inferencePipelineId + page = testResultListParams.page + perPage = testResultListParams.perPage + status = testResultListParams.status + type = testResultListParams.type + additionalHeaders = testResultListParams.additionalHeaders.toBuilder() + additionalQueryParams = testResultListParams.additionalQueryParams.toBuilder() + } + + fun inferencePipelineId(inferencePipelineId: String) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** The page to return in a paginated query. */ + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.getOrNull()) + + /** + * Filter list of test results by status. Available statuses are `running`, `passing`, + * `failing`, `skipped`, and `error`. + */ + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Filter objects by test type. Available types are `integrity`, `consistency`, + * `performance`, `fairness`, and `robustness`. + */ + fun type(type: Type?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.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 [TestResultListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .inferencePipelineId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TestResultListParams = + TestResultListParams( + checkRequired("inferencePipelineId", inferencePipelineId), + page, + perPage, + status, + type, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + status?.let { put("status", it.toString()) } + type?.let { put("type", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** + * Filter list of test results by status. Available statuses are `running`, `passing`, + * `failing`, `skipped`, and `error`. + */ + class Status @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 RUNNING = of("running") + + @JvmField val PASSING = of("passing") + + @JvmField val FAILING = of("failing") + + @JvmField val SKIPPED = of("skipped") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + /** An enum member indicating that [Status] 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) { + RUNNING -> Value.RUNNING + PASSING -> Value.PASSING + FAILING -> Value.FAILING + SKIPPED -> Value.SKIPPED + ERROR -> Value.ERROR + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUNNING -> Known.RUNNING + PASSING -> Known.PASSING + FAILING -> Known.FAILING + SKIPPED -> Known.SKIPPED + ERROR -> Known.ERROR + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Filter objects by test type. Available types are `integrity`, `consistency`, `performance`, + * `fairness`, and `robustness`. + */ + class Type @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 INTEGRITY = of("integrity") + + @JvmField val CONSISTENCY = of("consistency") + + @JvmField val PERFORMANCE = of("performance") + + @JvmField val FAIRNESS = of("fairness") + + @JvmField val ROBUSTNESS = of("robustness") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INTEGRITY, + CONSISTENCY, + PERFORMANCE, + FAIRNESS, + ROBUSTNESS, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + INTEGRITY, + CONSISTENCY, + PERFORMANCE, + FAIRNESS, + ROBUSTNESS, + /** An enum member indicating that [Type] 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) { + INTEGRITY -> Value.INTEGRITY + CONSISTENCY -> Value.CONSISTENCY + PERFORMANCE -> Value.PERFORMANCE + FAIRNESS -> Value.FAIRNESS + ROBUSTNESS -> Value.ROBUSTNESS + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + INTEGRITY -> Known.INTEGRITY + CONSISTENCY -> Known.CONSISTENCY + PERFORMANCE -> Known.PERFORMANCE + FAIRNESS -> Known.FAIRNESS + ROBUSTNESS -> Known.ROBUSTNESS + else -> throw OpenlayerInvalidDataException("Unknown Type: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TestResultListParams && inferencePipelineId == other.inferencePipelineId && page == other.page && perPage == other.perPage && status == other.status && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(inferencePipelineId, page, perPage, status, type, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "TestResultListParams{inferencePipelineId=$inferencePipelineId, page=$page, perPage=$perPage, status=$status, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt new file mode 100644 index 00000000..f43e5f63 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt @@ -0,0 +1,2605 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.testresults + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.BaseDeserializer +import com.openlayer.api.core.BaseSerializer +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.allMaxBy +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.getOrThrow +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TestResultListResponse +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 [TestResultListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TestResultListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(testResultListResponse: TestResultListResponse) = apply { + items = testResultListResponse.items.map { it.toMutableList() } + additionalProperties = testResultListResponse.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 [TestResultListResponse]. + * + * 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(): TestResultListResponse = + TestResultListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TestResultListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + class Item + private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateDataEnds: JsonField, + private val dateDataStarts: JsonField, + private val dateUpdated: JsonField, + private val inferencePipelineId: JsonField, + private val projectVersionId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val goal: JsonField, + private val goalId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateDataEnds") + @ExcludeMissing + dateDataEnds: JsonField = JsonMissing.of(), + @JsonProperty("dateDataStarts") + @ExcludeMissing + dateDataStarts: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineId") + @ExcludeMissing + inferencePipelineId: JsonField = JsonMissing.of(), + @JsonProperty("projectVersionId") + @ExcludeMissing + projectVersionId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("goal") @ExcludeMissing goal: JsonField = JsonMissing.of(), + @JsonProperty("goalId") @ExcludeMissing goalId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateDataEnds, + dateDataStarts, + dateUpdated, + inferencePipelineId, + projectVersionId, + status, + statusMessage, + goal, + goalId, + mutableMapOf(), + ) + + /** + * Project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The data end date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateDataEnds(): Optional = dateDataEnds.getOptional("dateDataEnds") + + /** + * The data start date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateDataStarts(): Optional = + dateDataStarts.getOptional("dateDataStarts") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inferencePipelineId(): Optional = + inferencePipelineId.getOptional("inferencePipelineId") + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun projectVersionId(): Optional = projectVersionId.getOptional("projectVersionId") + + /** + * The status of the test. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun goal(): Optional = goal.getOptional("goal") + + /** + * The test id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun goalId(): Optional = goalId.getOptional("goalId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateDataEnds]. + * + * Unlike [dateDataEnds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateDataEnds") + @ExcludeMissing + fun _dateDataEnds(): JsonField = dateDataEnds + + /** + * Returns the raw JSON value of [dateDataStarts]. + * + * Unlike [dateDataStarts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateDataStarts") + @ExcludeMissing + fun _dateDataStarts(): JsonField = dateDataStarts + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inferencePipelineId]. + * + * Unlike [inferencePipelineId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineId") + @ExcludeMissing + fun _inferencePipelineId(): JsonField = inferencePipelineId + + /** + * Returns the raw JSON value of [projectVersionId]. + * + * Unlike [projectVersionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectVersionId") + @ExcludeMissing + fun _projectVersionId(): JsonField = projectVersionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [goal]. + * + * Unlike [goal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goal") @ExcludeMissing fun _goal(): JsonField = goal + + /** + * Returns the raw JSON value of [goalId]. + * + * Unlike [goalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalId") @ExcludeMissing fun _goalId(): JsonField = goalId + + @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() + * .dateCreated() + * .dateDataEnds() + * .dateDataStarts() + * .dateUpdated() + * .inferencePipelineId() + * .projectVersionId() + * .status() + * .statusMessage() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateDataEnds: JsonField? = null + private var dateDataStarts: JsonField? = null + private var dateUpdated: JsonField? = null + private var inferencePipelineId: JsonField? = null + private var projectVersionId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var goal: JsonField = JsonMissing.of() + private var goalId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + dateCreated = item.dateCreated + dateDataEnds = item.dateDataEnds + dateDataStarts = item.dateDataStarts + dateUpdated = item.dateUpdated + inferencePipelineId = item.inferencePipelineId + projectVersionId = item.projectVersionId + status = item.status + statusMessage = item.statusMessage + goal = item.goal + goalId = item.goalId + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** Project version (commit) id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The data end date. */ + fun dateDataEnds(dateDataEnds: OffsetDateTime?) = + dateDataEnds(JsonField.ofNullable(dateDataEnds)) + + /** Alias for calling [Builder.dateDataEnds] with `dateDataEnds.orElse(null)`. */ + fun dateDataEnds(dateDataEnds: Optional) = + dateDataEnds(dateDataEnds.getOrNull()) + + /** + * Sets [Builder.dateDataEnds] to an arbitrary JSON value. + * + * You should usually call [Builder.dateDataEnds] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateDataEnds(dateDataEnds: JsonField) = apply { + this.dateDataEnds = dateDataEnds + } + + /** The data start date. */ + fun dateDataStarts(dateDataStarts: OffsetDateTime?) = + dateDataStarts(JsonField.ofNullable(dateDataStarts)) + + /** Alias for calling [Builder.dateDataStarts] with `dateDataStarts.orElse(null)`. */ + fun dateDataStarts(dateDataStarts: Optional) = + dateDataStarts(dateDataStarts.getOrNull()) + + /** + * Sets [Builder.dateDataStarts] to an arbitrary JSON value. + * + * You should usually call [Builder.dateDataStarts] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateDataStarts(dateDataStarts: JsonField) = apply { + this.dateDataStarts = dateDataStarts + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline id. */ + fun inferencePipelineId(inferencePipelineId: String?) = + inferencePipelineId(JsonField.ofNullable(inferencePipelineId)) + + /** + * Alias for calling [Builder.inferencePipelineId] with + * `inferencePipelineId.orElse(null)`. + */ + fun inferencePipelineId(inferencePipelineId: Optional) = + inferencePipelineId(inferencePipelineId.getOrNull()) + + /** + * Sets [Builder.inferencePipelineId] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineId(inferencePipelineId: JsonField) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** The project version (commit) id. */ + fun projectVersionId(projectVersionId: String?) = + projectVersionId(JsonField.ofNullable(projectVersionId)) + + /** + * Alias for calling [Builder.projectVersionId] with `projectVersionId.orElse(null)`. + */ + fun projectVersionId(projectVersionId: Optional) = + projectVersionId(projectVersionId.getOrNull()) + + /** + * Sets [Builder.projectVersionId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectVersionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectVersionId(projectVersionId: JsonField) = apply { + this.projectVersionId = projectVersionId + } + + /** The status of the test. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + fun goal(goal: Goal) = goal(JsonField.of(goal)) + + /** + * Sets [Builder.goal] to an arbitrary JSON value. + * + * You should usually call [Builder.goal] with a well-typed [Goal] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun goal(goal: JsonField) = apply { this.goal = goal } + + /** The test id. */ + fun goalId(goalId: String?) = goalId(JsonField.ofNullable(goalId)) + + /** Alias for calling [Builder.goalId] with `goalId.orElse(null)`. */ + fun goalId(goalId: Optional) = goalId(goalId.getOrNull()) + + /** + * Sets [Builder.goalId] to an arbitrary JSON value. + * + * You should usually call [Builder.goalId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalId(goalId: JsonField) = apply { this.goalId = goalId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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() + * .dateCreated() + * .dateDataEnds() + * .dateDataStarts() + * .dateUpdated() + * .inferencePipelineId() + * .projectVersionId() + * .status() + * .statusMessage() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateDataEnds", dateDataEnds), + checkRequired("dateDataStarts", dateDataStarts), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inferencePipelineId", inferencePipelineId), + checkRequired("projectVersionId", projectVersionId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + goal, + goalId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateDataEnds() + dateDataStarts() + dateUpdated() + inferencePipelineId() + projectVersionId() + status().validate() + statusMessage() + goal().ifPresent { it.validate() } + goalId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateDataEnds.asKnown().isPresent) 1 else 0) + + (if (dateDataStarts.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineId.asKnown().isPresent) 1 else 0) + + (if (projectVersionId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (goal.asKnown().getOrNull()?.validity() ?: 0) + + (if (goalId.asKnown().isPresent) 1 else 0) + + /** The status of the test. */ + class Status @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 RUNNING = of("running") + + @JvmField val PASSING = of("passing") + + @JvmField val FAILING = of("failing") + + @JvmField val SKIPPED = of("skipped") + + @JvmField val ERROR = of("error") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + RUNNING, + PASSING, + FAILING, + SKIPPED, + ERROR, + /** + * An enum member indicating that [Status] 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) { + RUNNING -> Value.RUNNING + PASSING -> Value.PASSING + FAILING -> Value.FAILING + SKIPPED -> Value.SKIPPED + ERROR -> Value.ERROR + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUNNING -> Known.RUNNING + PASSING -> Known.PASSING + FAILING -> Known.FAILING + SKIPPED -> Known.SKIPPED + ERROR -> Known.ERROR + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Goal + private constructor( + private val id: JsonField, + private val commentCount: JsonField, + private val creatorId: JsonField, + private val dateArchived: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val description: JsonValue, + private val name: JsonField, + private val number: JsonField, + private val originProjectVersionId: JsonField, + private val subtype: JsonField, + private val suggested: JsonField, + private val thresholds: JsonField>, + private val type: JsonField, + private val archived: JsonField, + private val delayWindow: JsonField, + private val evaluationWindow: JsonField, + private val usesMlModel: JsonField, + private val usesProductionData: JsonField, + private val usesReferenceDataset: JsonField, + private val usesTrainingDataset: JsonField, + private val usesValidationDataset: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("commentCount") + @ExcludeMissing + commentCount: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateArchived") + @ExcludeMissing + dateArchived: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonValue = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("number") @ExcludeMissing number: JsonField = JsonMissing.of(), + @JsonProperty("originProjectVersionId") + @ExcludeMissing + originProjectVersionId: JsonField = JsonMissing.of(), + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("suggested") + @ExcludeMissing + suggested: JsonField = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + thresholds: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("archived") + @ExcludeMissing + archived: JsonField = JsonMissing.of(), + @JsonProperty("delayWindow") + @ExcludeMissing + delayWindow: JsonField = JsonMissing.of(), + @JsonProperty("evaluationWindow") + @ExcludeMissing + evaluationWindow: JsonField = JsonMissing.of(), + @JsonProperty("usesMlModel") + @ExcludeMissing + usesMlModel: JsonField = JsonMissing.of(), + @JsonProperty("usesProductionData") + @ExcludeMissing + usesProductionData: JsonField = JsonMissing.of(), + @JsonProperty("usesReferenceDataset") + @ExcludeMissing + usesReferenceDataset: JsonField = JsonMissing.of(), + @JsonProperty("usesTrainingDataset") + @ExcludeMissing + usesTrainingDataset: JsonField = JsonMissing.of(), + @JsonProperty("usesValidationDataset") + @ExcludeMissing + usesValidationDataset: JsonField = JsonMissing.of(), + ) : this( + id, + commentCount, + creatorId, + dateArchived, + dateCreated, + dateUpdated, + description, + name, + number, + originProjectVersionId, + subtype, + suggested, + thresholds, + type, + archived, + delayWindow, + evaluationWindow, + usesMlModel, + usesProductionData, + usesReferenceDataset, + usesTrainingDataset, + usesValidationDataset, + mutableMapOf(), + ) + + /** + * The test id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of comments on the test. + * + * @throws OpenlayerInvalidDataException 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 commentCount(): Long = commentCount.getRequired("commentCount") + + /** + * The test creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The date the test was archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dateArchived(): Optional = dateArchived.getOptional("dateArchived") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** The test description. */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonValue = description + + /** + * The test name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The test number. + * + * @throws OpenlayerInvalidDataException 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 number(): Long = number.getRequired("number") + + /** + * The project version (commit) id where the test was created. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun originProjectVersionId(): Optional = + originProjectVersionId.getOptional("originProjectVersionId") + + /** + * The test subtype. + * + * @throws OpenlayerInvalidDataException 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 subtype(): String = subtype.getRequired("subtype") + + /** + * Whether the test is suggested or user-created. + * + * @throws OpenlayerInvalidDataException 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 suggested(): Boolean = suggested.getRequired("suggested") + + /** + * @throws OpenlayerInvalidDataException 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 thresholds(): List = thresholds.getRequired("thresholds") + + /** + * The test type. + * + * @throws OpenlayerInvalidDataException 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 type(): String = type.getRequired("type") + + /** + * Whether the test is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun archived(): Optional = archived.getOptional("archived") + + /** + * The delay window in seconds. Only applies to tests that use production data. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun delayWindow(): Optional = delayWindow.getOptional("delayWindow") + + /** + * The evaluation window in seconds. Only applies to tests that use production data. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun evaluationWindow(): Optional = + evaluationWindow.getOptional("evaluationWindow") + + /** + * Whether the test uses an ML model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesMlModel(): Optional = usesMlModel.getOptional("usesMlModel") + + /** + * Whether the test uses production data (monitoring mode only). + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesProductionData(): Optional = + usesProductionData.getOptional("usesProductionData") + + /** + * Whether the test uses a reference dataset (monitoring mode only). + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesReferenceDataset(): Optional = + usesReferenceDataset.getOptional("usesReferenceDataset") + + /** + * Whether the test uses a training dataset. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesTrainingDataset(): Optional = + usesTrainingDataset.getOptional("usesTrainingDataset") + + /** + * Whether the test uses a validation dataset. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun usesValidationDataset(): Optional = + usesValidationDataset.getOptional("usesValidationDataset") + + /** + * 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 [commentCount]. + * + * Unlike [commentCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("commentCount") + @ExcludeMissing + fun _commentCount(): JsonField = commentCount + + /** + * Returns the raw JSON value of [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("creatorId") + @ExcludeMissing + fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun _dateArchived(): JsonField = dateArchived + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * 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 [number]. + * + * Unlike [number], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("number") @ExcludeMissing fun _number(): JsonField = number + + /** + * Returns the raw JSON value of [originProjectVersionId]. + * + * Unlike [originProjectVersionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("originProjectVersionId") + @ExcludeMissing + fun _originProjectVersionId(): JsonField = originProjectVersionId + + /** + * Returns the raw JSON value of [subtype]. + * + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype + + /** + * Returns the raw JSON value of [suggested]. + * + * Unlike [suggested], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("suggested") + @ExcludeMissing + fun _suggested(): JsonField = suggested + + /** + * Returns the raw JSON value of [thresholds]. + * + * Unlike [thresholds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("archived") @ExcludeMissing fun _archived(): JsonField = archived + + /** + * Returns the raw JSON value of [delayWindow]. + * + * Unlike [delayWindow], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("delayWindow") + @ExcludeMissing + fun _delayWindow(): JsonField = delayWindow + + /** + * Returns the raw JSON value of [evaluationWindow]. + * + * Unlike [evaluationWindow], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("evaluationWindow") + @ExcludeMissing + fun _evaluationWindow(): JsonField = evaluationWindow + + /** + * Returns the raw JSON value of [usesMlModel]. + * + * Unlike [usesMlModel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("usesMlModel") + @ExcludeMissing + fun _usesMlModel(): JsonField = usesMlModel + + /** + * Returns the raw JSON value of [usesProductionData]. + * + * Unlike [usesProductionData], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesProductionData") + @ExcludeMissing + fun _usesProductionData(): JsonField = usesProductionData + + /** + * Returns the raw JSON value of [usesReferenceDataset]. + * + * Unlike [usesReferenceDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesReferenceDataset") + @ExcludeMissing + fun _usesReferenceDataset(): JsonField = usesReferenceDataset + + /** + * Returns the raw JSON value of [usesTrainingDataset]. + * + * Unlike [usesTrainingDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesTrainingDataset") + @ExcludeMissing + fun _usesTrainingDataset(): JsonField = usesTrainingDataset + + /** + * Returns the raw JSON value of [usesValidationDataset]. + * + * Unlike [usesValidationDataset], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("usesValidationDataset") + @ExcludeMissing + fun _usesValidationDataset(): JsonField = usesValidationDataset + + @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 [Goal]. + * + * The following fields are required: + * ```java + * .id() + * .commentCount() + * .creatorId() + * .dateArchived() + * .dateCreated() + * .dateUpdated() + * .description() + * .name() + * .number() + * .originProjectVersionId() + * .subtype() + * .suggested() + * .thresholds() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Goal]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var commentCount: JsonField? = null + private var creatorId: JsonField? = null + private var dateArchived: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonValue? = null + private var name: JsonField? = null + private var number: JsonField? = null + private var originProjectVersionId: JsonField? = null + private var subtype: JsonField? = null + private var suggested: JsonField? = null + private var thresholds: JsonField>? = null + private var type: JsonField? = null + private var archived: JsonField = JsonMissing.of() + private var delayWindow: JsonField = JsonMissing.of() + private var evaluationWindow: JsonField = JsonMissing.of() + private var usesMlModel: JsonField = JsonMissing.of() + private var usesProductionData: JsonField = JsonMissing.of() + private var usesReferenceDataset: JsonField = JsonMissing.of() + private var usesTrainingDataset: JsonField = JsonMissing.of() + private var usesValidationDataset: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(goal: Goal) = apply { + id = goal.id + commentCount = goal.commentCount + creatorId = goal.creatorId + dateArchived = goal.dateArchived + dateCreated = goal.dateCreated + dateUpdated = goal.dateUpdated + description = goal.description + name = goal.name + number = goal.number + originProjectVersionId = goal.originProjectVersionId + subtype = goal.subtype + suggested = goal.suggested + thresholds = goal.thresholds.map { it.toMutableList() } + type = goal.type + archived = goal.archived + delayWindow = goal.delayWindow + evaluationWindow = goal.evaluationWindow + usesMlModel = goal.usesMlModel + usesProductionData = goal.usesProductionData + usesReferenceDataset = goal.usesReferenceDataset + usesTrainingDataset = goal.usesTrainingDataset + usesValidationDataset = goal.usesValidationDataset + additionalProperties = goal.additionalProperties.toMutableMap() + } + + /** The test id. */ + 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 } + + /** The number of comments on the test. */ + fun commentCount(commentCount: Long) = commentCount(JsonField.of(commentCount)) + + /** + * Sets [Builder.commentCount] to an arbitrary JSON value. + * + * You should usually call [Builder.commentCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun commentCount(commentCount: JsonField) = apply { + this.commentCount = commentCount + } + + /** The test creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The date the test was archived. */ + fun dateArchived(dateArchived: OffsetDateTime?) = + dateArchived(JsonField.ofNullable(dateArchived)) + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The test description. */ + fun description(description: JsonValue) = apply { this.description = description } + + /** The test name. */ + 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 } + + /** The test number. */ + fun number(number: Long) = number(JsonField.of(number)) + + /** + * Sets [Builder.number] to an arbitrary JSON value. + * + * You should usually call [Builder.number] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun number(number: JsonField) = apply { this.number = number } + + /** The project version (commit) id where the test was created. */ + fun originProjectVersionId(originProjectVersionId: String?) = + originProjectVersionId(JsonField.ofNullable(originProjectVersionId)) + + /** + * Alias for calling [Builder.originProjectVersionId] with + * `originProjectVersionId.orElse(null)`. + */ + fun originProjectVersionId(originProjectVersionId: Optional) = + originProjectVersionId(originProjectVersionId.getOrNull()) + + /** + * Sets [Builder.originProjectVersionId] to an arbitrary JSON value. + * + * You should usually call [Builder.originProjectVersionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun originProjectVersionId(originProjectVersionId: JsonField) = apply { + this.originProjectVersionId = originProjectVersionId + } + + /** The test subtype. */ + fun subtype(subtype: String) = subtype(JsonField.of(subtype)) + + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + + /** Whether the test is suggested or user-created. */ + fun suggested(suggested: Boolean) = suggested(JsonField.of(suggested)) + + /** + * Sets [Builder.suggested] to an arbitrary JSON value. + * + * You should usually call [Builder.suggested] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun suggested(suggested: JsonField) = apply { this.suggested = suggested } + + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + + /** + * Sets [Builder.thresholds] to an arbitrary JSON value. + * + * You should usually call [Builder.thresholds] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** + * Adds a single [Threshold] to [thresholds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addThreshold(threshold: Threshold) = apply { + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).also { + checkKnown("thresholds", it).add(threshold) + } + } + + /** The test type. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Whether the test is archived. */ + fun archived(archived: Boolean) = archived(JsonField.of(archived)) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The delay window in seconds. Only applies to tests that use production data. */ + fun delayWindow(delayWindow: Double?) = + delayWindow(JsonField.ofNullable(delayWindow)) + + /** + * Alias for [Builder.delayWindow]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun delayWindow(delayWindow: Double) = delayWindow(delayWindow as Double?) + + /** Alias for calling [Builder.delayWindow] with `delayWindow.orElse(null)`. */ + fun delayWindow(delayWindow: Optional) = + delayWindow(delayWindow.getOrNull()) + + /** + * Sets [Builder.delayWindow] to an arbitrary JSON value. + * + * You should usually call [Builder.delayWindow] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun delayWindow(delayWindow: JsonField) = apply { + this.delayWindow = delayWindow + } + + /** + * The evaluation window in seconds. Only applies to tests that use production data. + */ + fun evaluationWindow(evaluationWindow: Double?) = + evaluationWindow(JsonField.ofNullable(evaluationWindow)) + + /** + * Alias for [Builder.evaluationWindow]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun evaluationWindow(evaluationWindow: Double) = + evaluationWindow(evaluationWindow as Double?) + + /** + * Alias for calling [Builder.evaluationWindow] with + * `evaluationWindow.orElse(null)`. + */ + fun evaluationWindow(evaluationWindow: Optional) = + evaluationWindow(evaluationWindow.getOrNull()) + + /** + * Sets [Builder.evaluationWindow] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluationWindow] with a well-typed [Double] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun evaluationWindow(evaluationWindow: JsonField) = apply { + this.evaluationWindow = evaluationWindow + } + + /** Whether the test uses an ML model. */ + fun usesMlModel(usesMlModel: Boolean) = usesMlModel(JsonField.of(usesMlModel)) + + /** + * Sets [Builder.usesMlModel] to an arbitrary JSON value. + * + * You should usually call [Builder.usesMlModel] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun usesMlModel(usesMlModel: JsonField) = apply { + this.usesMlModel = usesMlModel + } + + /** Whether the test uses production data (monitoring mode only). */ + fun usesProductionData(usesProductionData: Boolean) = + usesProductionData(JsonField.of(usesProductionData)) + + /** + * Sets [Builder.usesProductionData] to an arbitrary JSON value. + * + * You should usually call [Builder.usesProductionData] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun usesProductionData(usesProductionData: JsonField) = apply { + this.usesProductionData = usesProductionData + } + + /** Whether the test uses a reference dataset (monitoring mode only). */ + fun usesReferenceDataset(usesReferenceDataset: Boolean) = + usesReferenceDataset(JsonField.of(usesReferenceDataset)) + + /** + * Sets [Builder.usesReferenceDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.usesReferenceDataset] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usesReferenceDataset(usesReferenceDataset: JsonField) = apply { + this.usesReferenceDataset = usesReferenceDataset + } + + /** Whether the test uses a training dataset. */ + fun usesTrainingDataset(usesTrainingDataset: Boolean) = + usesTrainingDataset(JsonField.of(usesTrainingDataset)) + + /** + * Sets [Builder.usesTrainingDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.usesTrainingDataset] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun usesTrainingDataset(usesTrainingDataset: JsonField) = apply { + this.usesTrainingDataset = usesTrainingDataset + } + + /** Whether the test uses a validation dataset. */ + fun usesValidationDataset(usesValidationDataset: Boolean) = + usesValidationDataset(JsonField.of(usesValidationDataset)) + + /** + * Sets [Builder.usesValidationDataset] to an arbitrary JSON value. + * + * You should usually call [Builder.usesValidationDataset] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun usesValidationDataset(usesValidationDataset: JsonField) = apply { + this.usesValidationDataset = usesValidationDataset + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Goal]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commentCount() + * .creatorId() + * .dateArchived() + * .dateCreated() + * .dateUpdated() + * .description() + * .name() + * .number() + * .originProjectVersionId() + * .subtype() + * .suggested() + * .thresholds() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Goal = + Goal( + checkRequired("id", id), + checkRequired("commentCount", commentCount), + checkRequired("creatorId", creatorId), + checkRequired("dateArchived", dateArchived), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("name", name), + checkRequired("number", number), + checkRequired("originProjectVersionId", originProjectVersionId), + checkRequired("subtype", subtype), + checkRequired("suggested", suggested), + checkRequired("thresholds", thresholds).map { it.toImmutable() }, + checkRequired("type", type), + archived, + delayWindow, + evaluationWindow, + usesMlModel, + usesProductionData, + usesReferenceDataset, + usesTrainingDataset, + usesValidationDataset, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Goal = apply { + if (validated) { + return@apply + } + + id() + commentCount() + creatorId() + dateArchived() + dateCreated() + dateUpdated() + name() + number() + originProjectVersionId() + subtype() + suggested() + thresholds().forEach { it.validate() } + type() + archived() + delayWindow() + evaluationWindow() + usesMlModel() + usesProductionData() + usesReferenceDataset() + usesTrainingDataset() + usesValidationDataset() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (commentCount.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (number.asKnown().isPresent) 1 else 0) + + (if (originProjectVersionId.asKnown().isPresent) 1 else 0) + + (if (subtype.asKnown().isPresent) 1 else 0) + + (if (suggested.asKnown().isPresent) 1 else 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (delayWindow.asKnown().isPresent) 1 else 0) + + (if (evaluationWindow.asKnown().isPresent) 1 else 0) + + (if (usesMlModel.asKnown().isPresent) 1 else 0) + + (if (usesProductionData.asKnown().isPresent) 1 else 0) + + (if (usesReferenceDataset.asKnown().isPresent) 1 else 0) + + (if (usesTrainingDataset.asKnown().isPresent) 1 else 0) + + (if (usesValidationDataset.asKnown().isPresent) 1 else 0) + + class Threshold + private constructor( + private val insightName: JsonField, + private val insightParameters: JsonField>, + private val measurement: JsonField, + private val operator: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("insightName") + @ExcludeMissing + insightName: JsonField = JsonMissing.of(), + @JsonProperty("insightParameters") + @ExcludeMissing + insightParameters: JsonField> = JsonMissing.of(), + @JsonProperty("measurement") + @ExcludeMissing + measurement: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this( + insightName, + insightParameters, + measurement, + operator, + value, + mutableMapOf(), + ) + + /** + * The insight name to be evaluated. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun insightName(): Optional = insightName.getOptional("insightName") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun insightParameters(): Optional> = + insightParameters.getOptional("insightParameters") + + /** + * The measurement to be evaluated. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun measurement(): Optional = measurement.getOptional("measurement") + + /** + * The operator to be used for the evaluation. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun operator(): Optional = operator.getOptional("operator") + + /** + * The value to be compared. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [insightName]. + * + * Unlike [insightName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("insightName") + @ExcludeMissing + fun _insightName(): JsonField = insightName + + /** + * Returns the raw JSON value of [insightParameters]. + * + * Unlike [insightParameters], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("insightParameters") + @ExcludeMissing + fun _insightParameters(): JsonField> = insightParameters + + /** + * Returns the raw JSON value of [measurement]. + * + * Unlike [measurement], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("measurement") + @ExcludeMissing + fun _measurement(): JsonField = measurement + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [Threshold]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Threshold]. */ + class Builder internal constructor() { + + private var insightName: JsonField = JsonMissing.of() + private var insightParameters: JsonField>? = null + private var measurement: JsonField = JsonMissing.of() + private var operator: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(threshold: Threshold) = apply { + insightName = threshold.insightName + insightParameters = threshold.insightParameters.map { it.toMutableList() } + measurement = threshold.measurement + operator = threshold.operator + value = threshold.value + additionalProperties = threshold.additionalProperties.toMutableMap() + } + + /** The insight name to be evaluated. */ + fun insightName(insightName: String) = insightName(JsonField.of(insightName)) + + /** + * Sets [Builder.insightName] to an arbitrary JSON value. + * + * You should usually call [Builder.insightName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun insightName(insightName: JsonField) = apply { + this.insightName = insightName + } + + fun insightParameters(insightParameters: List) = + insightParameters(JsonField.of(insightParameters)) + + /** + * Sets [Builder.insightParameters] to an arbitrary JSON value. + * + * You should usually call [Builder.insightParameters] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun insightParameters(insightParameters: JsonField>) = apply { + this.insightParameters = insightParameters.map { it.toMutableList() } + } + + /** + * Adds a single [JsonValue] to [insightParameters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addInsightParameter(insightParameter: JsonValue) = apply { + insightParameters = + (insightParameters ?: JsonField.of(mutableListOf())).also { + checkKnown("insightParameters", it).add(insightParameter) + } + } + + /** The measurement to be evaluated. */ + fun measurement(measurement: String) = measurement(JsonField.of(measurement)) + + /** + * Sets [Builder.measurement] to an arbitrary JSON value. + * + * You should usually call [Builder.measurement] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun measurement(measurement: JsonField) = apply { + this.measurement = measurement + } + + /** The operator to be used for the evaluation. */ + fun operator(operator: String) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** The value to be compared. */ + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofStrings(strings)`. */ + fun valueOfStrings(strings: List) = value(Value.ofStrings(strings)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Threshold]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Threshold = + Threshold( + insightName, + (insightParameters ?: JsonMissing.of()).map { it.toImmutable() }, + measurement, + operator, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Threshold = apply { + if (validated) { + return@apply + } + + insightName() + insightParameters() + measurement() + operator() + value().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (insightName.asKnown().isPresent) 1 else 0) + + (insightParameters.asKnown().getOrNull()?.size ?: 0) + + (if (measurement.asKnown().isPresent) 1 else 0) + + (if (operator.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + /** The value to be compared. */ + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val number: Double? = null, + private val bool: Boolean? = null, + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asString(): String = string.getOrThrow("string") + + fun asStrings(): List = strings.getOrThrow("strings") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitString(string: String) {} + + override fun visitStrings(strings: List) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Value && number == other.number && bool == other.bool && string == other.string && strings == other.strings /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(number, bool, string, strings) /* spotless:on */ + + override fun toString(): String = + when { + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + string != null -> "Value{string=$string}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) + } + + /** + * An interface that defines how to map each variant of [Value] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitString(string: String): T + + fun visitStrings(strings: List): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws OpenlayerInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenlayerInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.string != null -> generator.writeObject(value.string) + value.strings != null -> generator.writeObject(value.strings) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Threshold && insightName == other.insightName && insightParameters == other.insightParameters && measurement == other.measurement && operator == other.operator && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(insightName, insightParameters, measurement, operator, value, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Threshold{insightName=$insightName, insightParameters=$insightParameters, measurement=$measurement, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Goal && id == other.id && commentCount == other.commentCount && creatorId == other.creatorId && dateArchived == other.dateArchived && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && description == other.description && name == other.name && number == other.number && originProjectVersionId == other.originProjectVersionId && subtype == other.subtype && suggested == other.suggested && thresholds == other.thresholds && type == other.type && archived == other.archived && delayWindow == other.delayWindow && evaluationWindow == other.evaluationWindow && usesMlModel == other.usesMlModel && usesProductionData == other.usesProductionData && usesReferenceDataset == other.usesReferenceDataset && usesTrainingDataset == other.usesTrainingDataset && usesValidationDataset == other.usesValidationDataset && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, commentCount, creatorId, dateArchived, dateCreated, dateUpdated, description, name, number, originProjectVersionId, subtype, suggested, thresholds, type, archived, delayWindow, evaluationWindow, usesMlModel, usesProductionData, usesReferenceDataset, usesTrainingDataset, usesValidationDataset, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Goal{id=$id, commentCount=$commentCount, creatorId=$creatorId, dateArchived=$dateArchived, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, name=$name, number=$number, originProjectVersionId=$originProjectVersionId, subtype=$subtype, suggested=$suggested, thresholds=$thresholds, type=$type, archived=$archived, delayWindow=$delayWindow, evaluationWindow=$evaluationWindow, usesMlModel=$usesMlModel, usesProductionData=$usesProductionData, usesReferenceDataset=$usesReferenceDataset, usesTrainingDataset=$usesTrainingDataset, usesValidationDataset=$usesValidationDataset, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Item && id == other.id && dateCreated == other.dateCreated && dateDataEnds == other.dateDataEnds && dateDataStarts == other.dateDataStarts && dateUpdated == other.dateUpdated && inferencePipelineId == other.inferencePipelineId && projectVersionId == other.projectVersionId && status == other.status && statusMessage == other.statusMessage && goal == other.goal && goalId == other.goalId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateDataEnds, dateDataStarts, dateUpdated, inferencePipelineId, projectVersionId, status, statusMessage, goal, goalId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, dateCreated=$dateCreated, dateDataEnds=$dateDataEnds, dateDataStarts=$dateDataStarts, dateUpdated=$dateUpdated, inferencePipelineId=$inferencePipelineId, projectVersionId=$projectVersionId, status=$status, statusMessage=$statusMessage, goal=$goal, goalId=$goalId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is TestResultListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TestResultListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt new file mode 100644 index 00000000..e3a8a42c --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt @@ -0,0 +1,2489 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a project in your workspace. */ +class ProjectCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 = body.id() + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creatorId(): Optional = body.creatorId() + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = body.dateCreated() + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = body.dateUpdated() + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = body.developmentGoalCount() + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = body.goalCount() + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = body.inferencePipelineCount() + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = body.links() + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = body.monitoringGoalCount() + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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() + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = body.source() + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = body.taskType() + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = body.versionCount() + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = body.workspaceId() + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gitRepo(): Optional = body.gitRepo() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField = body._id() + + /** + * Returns the raw JSON value of [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _creatorId(): JsonField = body._creatorId() + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dateCreated(): JsonField = body._dateCreated() + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dateUpdated(): JsonField = body._dateUpdated() + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _developmentGoalCount(): JsonField = body._developmentGoalCount() + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _goalCount(): JsonField = body._goalCount() + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _inferencePipelineCount(): JsonField = body._inferencePipelineCount() + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _links(): JsonField = body._links() + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _monitoringGoalCount(): JsonField = body._monitoringGoalCount() + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _source(): JsonField = body._source() + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _taskType(): JsonField = body._taskType() + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _versionCount(): JsonField = body._versionCount() + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _workspaceId(): JsonField = body._workspaceId() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _gitRepo(): JsonField = body._gitRepo() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProjectCreateParams]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProjectCreateParams]. */ + 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(projectCreateParams: ProjectCreateParams) = apply { + body = projectCreateParams.body.toBuilder() + additionalHeaders = projectCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = projectCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + * - [creatorId] + * - [dateCreated] + * - [dateUpdated] + * - [developmentGoalCount] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The project id. */ + fun id(id: String) = apply { body.id(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 { body.id(id) } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = apply { body.creatorId(creatorId) } + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creatorId(creatorId: JsonField) = apply { body.creatorId(creatorId) } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = apply { body.dateCreated(dateCreated) } + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + body.dateCreated(dateCreated) + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = apply { body.dateUpdated(dateUpdated) } + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + body.dateUpdated(dateUpdated) + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = apply { + body.developmentGoalCount(developmentGoalCount) + } + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + body.developmentGoalCount(developmentGoalCount) + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = apply { body.goalCount(goalCount) } + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun goalCount(goalCount: JsonField) = apply { body.goalCount(goalCount) } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = apply { + body.inferencePipelineCount(inferencePipelineCount) + } + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + body.inferencePipelineCount(inferencePipelineCount) + } + + /** Links to the project. */ + fun links(links: Links) = apply { body.links(links) } + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { body.links(links) } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = apply { + body.monitoringGoalCount(monitoringGoalCount) + } + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + body.monitoringGoalCount(monitoringGoalCount) + } + + /** The project name. */ + 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) } + + /** The source of the project. */ + fun source(source: Source?) = apply { body.source(source) } + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { body.source(source) } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = apply { body.taskType(taskType) } + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun taskType(taskType: JsonField) = apply { body.taskType(taskType) } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = apply { body.versionCount(versionCount) } + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun versionCount(versionCount: JsonField) = apply { body.versionCount(versionCount) } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = apply { body.workspaceId(workspaceId) } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { body.workspaceId(workspaceId) } + + /** The project description. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + fun gitRepo(gitRepo: GitRepo?) = apply { body.gitRepo(gitRepo) } + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { body.gitRepo(gitRepo) } + + 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 [ProjectCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProjectCreateParams = + ProjectCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + creatorId = body.creatorId + dateCreated = body.dateCreated + dateUpdated = body.dateUpdated + developmentGoalCount = body.developmentGoalCount + goalCount = body.goalCount + inferencePipelineCount = body.inferencePipelineCount + links = body.links + monitoringGoalCount = body.monitoringGoalCount + name = body.name + source = body.source + taskType = body.taskType + versionCount = body.versionCount + workspaceId = body.workspaceId + description = body.description + gitRepo = body.gitRepo + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** An enum member indicating that [TaskType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") @ExcludeMissing branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") @ExcludeMissing rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCreateParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "ProjectCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt new file mode 100644 index 00000000..e6709bce --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt @@ -0,0 +1,1765 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ProjectCreateResponse +private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") @ExcludeMissing creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") @ExcludeMissing goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") @ExcludeMissing taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 [ProjectCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProjectCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectCreateResponse: ProjectCreateResponse) = apply { + id = projectCreateResponse.id + creatorId = projectCreateResponse.creatorId + dateCreated = projectCreateResponse.dateCreated + dateUpdated = projectCreateResponse.dateUpdated + developmentGoalCount = projectCreateResponse.developmentGoalCount + goalCount = projectCreateResponse.goalCount + inferencePipelineCount = projectCreateResponse.inferencePipelineCount + links = projectCreateResponse.links + monitoringGoalCount = projectCreateResponse.monitoringGoalCount + name = projectCreateResponse.name + source = projectCreateResponse.source + taskType = projectCreateResponse.taskType + versionCount = projectCreateResponse.versionCount + workspaceId = projectCreateResponse.workspaceId + description = projectCreateResponse.description + gitRepo = projectCreateResponse.gitRepo + additionalProperties = projectCreateResponse.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun versionCount(versionCount: JsonField) = apply { this.versionCount = versionCount } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProjectCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProjectCreateResponse = + ProjectCreateResponse( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProjectCreateResponse = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** An enum member indicating that [TaskType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") @ExcludeMissing branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") @ExcludeMissing rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCreateResponse && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProjectCreateResponse{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt similarity index 60% rename from openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectListParams.kt rename to openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt index c4959e47..737094b5 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectListParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt @@ -1,61 +1,57 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.projects import com.fasterxml.jackson.annotation.JsonCreator import com.openlayer.api.core.Enum import com.openlayer.api.core.JsonField -import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.Params import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import com.openlayer.api.errors.OpenlayerInvalidDataException import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull +/** List your workspace's projects. */ class ProjectListParams -constructor( +private constructor( private val name: String?, private val page: Long?, private val perPage: Long?, private val taskType: TaskType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { + /** Filter list of items by project name. */ fun name(): Optional = Optional.ofNullable(name) + /** The page to return in a paginated query. */ fun page(): Optional = Optional.ofNullable(page) + /** Maximum number of items to return per page. */ fun perPage(): Optional = Optional.ofNullable(perPage) + /** Filter list of items by task type. */ fun taskType(): Optional = Optional.ofNullable(taskType) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.name?.let { queryParams.put("name", listOf(it.toString())) } - this.page?.let { queryParams.put("page", listOf(it.toString())) } - this.perPage?.let { queryParams.put("perPage", listOf(it.toString())) } - this.taskType?.let { queryParams.put("taskType", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - fun toBuilder() = Builder().from(this) companion object { + @JvmStatic fun none(): ProjectListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ProjectListParams]. */ @JvmStatic fun builder() = Builder() } - @NoAutoDetect - class Builder { + /** A builder for [ProjectListParams]. */ + class Builder internal constructor() { private var name: String? = null private var page: Long? = null @@ -75,16 +71,42 @@ constructor( } /** Filter list of items by project name. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) /** The page to return in a paginated query. */ - fun page(page: Long) = apply { this.page = page } + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) /** Maximum number of items to return per page. */ - fun perPage(perPage: Long) = apply { this.perPage = perPage } + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.getOrNull()) /** Filter list of items by task type. */ - fun taskType(taskType: TaskType) = apply { this.taskType = taskType } + fun taskType(taskType: TaskType?) = apply { this.taskType = taskType } + + /** Alias for calling [Builder.taskType] with `taskType.orElse(null)`. */ + fun taskType(taskType: Optional) = taskType(taskType.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -184,6 +206,11 @@ constructor( additionalQueryParams.removeAll(keys) } + /** + * Returns an immutable instance of [ProjectListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ fun build(): ProjectListParams = ProjectListParams( name, @@ -195,12 +222,30 @@ constructor( ) } - class TaskType - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { + override fun _headers(): Headers = additionalHeaders + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + name?.let { put("name", it) } + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + taskType?.let { put("taskType", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Filter list of items by task type. */ + class TaskType @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 { @@ -216,6 +261,7 @@ constructor( @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) } + /** An enum containing [TaskType]'s known values. */ enum class Known { LLM_BASE, TABULAR_CLASSIFICATION, @@ -223,14 +269,31 @@ constructor( TEXT_CLASSIFICATION, } + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ enum class Value { LLM_BASE, TABULAR_CLASSIFICATION, TABULAR_REGRESSION, TEXT_CLASSIFICATION, + /** An enum member indicating that [TaskType] was instantiated with an unknown value. */ _UNKNOWN, } + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ fun value(): Value = when (this) { LLM_BASE -> Value.LLM_BASE @@ -240,6 +303,15 @@ constructor( 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ fun known(): Known = when (this) { LLM_BASE -> Known.LLM_BASE @@ -249,7 +321,46 @@ constructor( else -> throw OpenlayerInvalidDataException("Unknown TaskType: $value") } - fun asString(): String = _value().asStringOrThrow() + /** + * 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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) { diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt new file mode 100644 index 00000000..c8bd6d45 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt @@ -0,0 +1,1991 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ProjectListResponse +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 [ProjectListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProjectListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectListResponse: ProjectListResponse) = apply { + items = projectListResponse.items.map { it.toMutableList() } + additionalProperties = projectListResponse.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 [ProjectListResponse]. + * + * 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(): ProjectListResponse = + ProjectListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProjectListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + class Item + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + creatorId = item.creatorId + dateCreated = item.dateCreated + dateUpdated = item.dateUpdated + developmentGoalCount = item.developmentGoalCount + goalCount = item.goalCount + inferencePipelineCount = item.inferencePipelineCount + links = item.links + monitoringGoalCount = item.monitoringGoalCount + name = item.name + source = item.source + taskType = item.taskType + versionCount = item.versionCount + workspaceId = item.workspaceId + description = item.description + gitRepo = item.gitRepo + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** + * An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** + * An enum member indicating that [TaskType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") + @ExcludeMissing + rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Item && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProjectListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt new file mode 100644 index 00000000..d616219c --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt @@ -0,0 +1,2619 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new commit (project version) in a project. */ +class CommitCreateParams +private constructor( + private val pathProjectId: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun pathProjectId(): String = pathProjectId + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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 = body.id() + + /** + * The details of a commit (project version). + * + * @throws OpenlayerInvalidDataException 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 commit(): Commit = body.commit() + + /** + * The commit archive date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateArchived(): Optional = body.dateArchived() + + /** + * The project version (commit) creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = body.dateCreated() + + /** + * The number of tests that are failing for the commit. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = body.failingGoalCount() + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mlModelId(): Optional = body.mlModelId() + + /** + * The number of tests that are passing for the commit. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = body.passingGoalCount() + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 bodyProjectId(): String = body.bodyProjectId() + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = body.status() + + /** + * The commit status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = body.statusMessage() + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = body.storageUri() + + /** + * The total number of tests for the commit. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = body.totalGoalCount() + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = body.trainingDatasetId() + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = body.validationDatasetId() + + /** + * Whether the commit is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun archived(): Optional = body.archived() + + /** + * The deployment status associated with the commit's model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deploymentStatus(): Optional = body.deploymentStatus() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun links(): Optional = body.links() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField = body._id() + + /** + * Returns the raw JSON value of [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _commit(): JsonField = body._commit() + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dateArchived(): JsonField = body._dateArchived() + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dateCreated(): JsonField = body._dateCreated() + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _failingGoalCount(): JsonField = body._failingGoalCount() + + /** + * Returns the raw JSON value of [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _mlModelId(): JsonField = body._mlModelId() + + /** + * Returns the raw JSON value of [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _passingGoalCount(): JsonField = body._passingGoalCount() + + /** + * Returns the raw JSON value of [bodyProjectId]. + * + * Unlike [bodyProjectId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bodyProjectId(): JsonField = body._bodyProjectId() + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _status(): JsonField = body._status() + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _statusMessage(): JsonField = body._statusMessage() + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _storageUri(): JsonField = body._storageUri() + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _totalGoalCount(): JsonField = body._totalGoalCount() + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _trainingDatasetId(): JsonField = body._trainingDatasetId() + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _validationDatasetId(): JsonField = body._validationDatasetId() + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _archived(): JsonField = body._archived() + + /** + * Returns the raw JSON value of [deploymentStatus]. + * + * Unlike [deploymentStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _deploymentStatus(): JsonField = body._deploymentStatus() + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _links(): JsonField = body._links() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CommitCreateParams]. + * + * The following fields are required: + * ```java + * .pathProjectId() + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitCreateParams]. */ + class Builder internal constructor() { + + private var pathProjectId: 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(commitCreateParams: CommitCreateParams) = apply { + pathProjectId = commitCreateParams.pathProjectId + body = commitCreateParams.body.toBuilder() + additionalHeaders = commitCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = commitCreateParams.additionalQueryParams.toBuilder() + } + + fun pathProjectId(pathProjectId: String) = apply { this.pathProjectId = pathProjectId } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + * - [commit] + * - [dateArchived] + * - [dateCreated] + * - [failingGoalCount] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The project version (commit) id. */ + fun id(id: String) = apply { body.id(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 { body.id(id) } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = apply { body.commit(commit) } + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [Commit] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commit(commit: JsonField) = apply { body.commit(commit) } + + /** The commit archive date. */ + fun dateArchived(dateArchived: OffsetDateTime?) = apply { body.dateArchived(dateArchived) } + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + body.dateArchived(dateArchived) + } + + /** The project version (commit) creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = apply { body.dateCreated(dateCreated) } + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + body.dateCreated(dateCreated) + } + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(failingGoalCount: Long) = apply { + body.failingGoalCount(failingGoalCount) + } + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + body.failingGoalCount(failingGoalCount) + } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = apply { body.mlModelId(mlModelId) } + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mlModelId(mlModelId: JsonField) = apply { body.mlModelId(mlModelId) } + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(passingGoalCount: Long) = apply { + body.passingGoalCount(passingGoalCount) + } + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + body.passingGoalCount(passingGoalCount) + } + + /** The project id. */ + fun bodyProjectId(bodyProjectId: String) = apply { body.bodyProjectId(bodyProjectId) } + + /** + * Sets [Builder.bodyProjectId] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyProjectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bodyProjectId(bodyProjectId: JsonField) = apply { + body.bodyProjectId(bodyProjectId) + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(status: Status) = apply { body.status(status) } + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { body.status(status) } + + /** The commit status message. */ + fun statusMessage(statusMessage: String?) = apply { body.statusMessage(statusMessage) } + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + body.statusMessage(statusMessage) + } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = apply { body.storageUri(storageUri) } + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun storageUri(storageUri: JsonField) = apply { body.storageUri(storageUri) } + + /** The total number of tests for the commit. */ + fun totalGoalCount(totalGoalCount: Long) = apply { body.totalGoalCount(totalGoalCount) } + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + body.totalGoalCount(totalGoalCount) + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = apply { + body.trainingDatasetId(trainingDatasetId) + } + + /** Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + body.trainingDatasetId(trainingDatasetId) + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = apply { + body.validationDatasetId(validationDatasetId) + } + + /** + * Alias for calling [Builder.validationDatasetId] with `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + body.validationDatasetId(validationDatasetId) + } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean?) = apply { body.archived(archived) } + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun archived(archived: JsonField) = apply { body.archived(archived) } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = apply { + body.deploymentStatus(deploymentStatus) + } + + /** + * Sets [Builder.deploymentStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentStatus] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deploymentStatus(deploymentStatus: JsonField) = apply { + body.deploymentStatus(deploymentStatus) + } + + fun links(links: Links) = apply { body.links(links) } + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { body.links(links) } + + 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 [CommitCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .pathProjectId() + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitCreateParams = + CommitCreateParams( + checkRequired("pathProjectId", pathProjectId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> pathProjectId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val id: JsonField, + private val commit: JsonField, + private val dateArchived: JsonField, + private val dateCreated: JsonField, + private val failingGoalCount: JsonField, + private val mlModelId: JsonField, + private val passingGoalCount: JsonField, + private val bodyProjectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val storageUri: JsonField, + private val totalGoalCount: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val archived: JsonField, + private val deploymentStatus: JsonField, + private val links: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), + @JsonProperty("dateArchived") + @ExcludeMissing + dateArchived: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") + @ExcludeMissing + mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + bodyProjectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("archived") + @ExcludeMissing + archived: JsonField = JsonMissing.of(), + @JsonProperty("deploymentStatus") + @ExcludeMissing + deploymentStatus: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + ) : this( + id, + commit, + dateArchived, + dateCreated, + failingGoalCount, + mlModelId, + passingGoalCount, + bodyProjectId, + status, + statusMessage, + storageUri, + totalGoalCount, + trainingDatasetId, + validationDatasetId, + archived, + deploymentStatus, + links, + mutableMapOf(), + ) + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The details of a commit (project version). + * + * @throws OpenlayerInvalidDataException 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 commit(): Commit = commit.getRequired("commit") + + /** + * The commit archive date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateArchived(): Optional = dateArchived.getOptional("dateArchived") + + /** + * The project version (commit) creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The number of tests that are failing for the commit. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The number of tests that are passing for the commit. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 bodyProjectId(): String = bodyProjectId.getRequired("projectId") + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The commit status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The total number of tests for the commit. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = + trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * Whether the commit is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun archived(): Optional = archived.getOptional("archived") + + /** + * The deployment status associated with the commit's model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deploymentStatus(): Optional = deploymentStatus.getOptional("deploymentStatus") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun links(): Optional = links.getOptional("links") + + /** + * 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 [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun _dateArchived(): JsonField = dateArchived + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [bodyProjectId]. + * + * Unlike [bodyProjectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _bodyProjectId(): JsonField = bodyProjectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") + @ExcludeMissing + fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("archived") @ExcludeMissing fun _archived(): JsonField = archived + + /** + * Returns the raw JSON value of [deploymentStatus]. + * + * Unlike [deploymentStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deploymentStatus") + @ExcludeMissing + fun _deploymentStatus(): JsonField = deploymentStatus + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + @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 + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var commit: JsonField? = null + private var dateArchived: JsonField? = null + private var dateCreated: JsonField? = null + private var failingGoalCount: JsonField? = null + private var mlModelId: JsonField? = null + private var passingGoalCount: JsonField? = null + private var bodyProjectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var storageUri: JsonField? = null + private var totalGoalCount: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var archived: JsonField = JsonMissing.of() + private var deploymentStatus: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + commit = body.commit + dateArchived = body.dateArchived + dateCreated = body.dateCreated + failingGoalCount = body.failingGoalCount + mlModelId = body.mlModelId + passingGoalCount = body.passingGoalCount + bodyProjectId = body.bodyProjectId + status = body.status + statusMessage = body.statusMessage + storageUri = body.storageUri + totalGoalCount = body.totalGoalCount + trainingDatasetId = body.trainingDatasetId + validationDatasetId = body.validationDatasetId + archived = body.archived + deploymentStatus = body.deploymentStatus + links = body.links + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The project version (commit) id. */ + 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 } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = commit(JsonField.of(commit)) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [Commit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** The commit archive date. */ + fun dateArchived(dateArchived: OffsetDateTime?) = + dateArchived(JsonField.ofNullable(dateArchived)) + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The project version (commit) creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun bodyProjectId(bodyProjectId: String) = bodyProjectId(JsonField.of(bodyProjectId)) + + /** + * Sets [Builder.bodyProjectId] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyProjectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bodyProjectId(bodyProjectId: JsonField) = apply { + this.bodyProjectId = bodyProjectId + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The commit status message. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The total number of tests for the commit. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** + * Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. + */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with + * `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean?) = archived(JsonField.ofNullable(archived)) + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = + deploymentStatus(JsonField.of(deploymentStatus)) + + /** + * Sets [Builder.deploymentStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentStatus] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deploymentStatus(deploymentStatus: JsonField) = apply { + this.deploymentStatus = deploymentStatus + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("id", id), + checkRequired("commit", commit), + checkRequired("dateArchived", dateArchived), + checkRequired("dateCreated", dateCreated), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("mlModelId", mlModelId), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("bodyProjectId", bodyProjectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("storageUri", storageUri), + checkRequired("totalGoalCount", totalGoalCount), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + archived, + deploymentStatus, + links, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + commit().validate() + dateArchived() + dateCreated() + failingGoalCount() + mlModelId() + passingGoalCount() + bodyProjectId() + status().validate() + statusMessage() + storageUri() + totalGoalCount() + trainingDatasetId() + validationDatasetId() + archived() + deploymentStatus() + links().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (bodyProjectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && id == other.id && commit == other.commit && dateArchived == other.dateArchived && dateCreated == other.dateCreated && failingGoalCount == other.failingGoalCount && mlModelId == other.mlModelId && passingGoalCount == other.passingGoalCount && bodyProjectId == other.bodyProjectId && status == other.status && statusMessage == other.statusMessage && storageUri == other.storageUri && totalGoalCount == other.totalGoalCount && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && archived == other.archived && deploymentStatus == other.deploymentStatus && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, commit, dateArchived, dateCreated, failingGoalCount, mlModelId, passingGoalCount, bodyProjectId, status, statusMessage, storageUri, totalGoalCount, trainingDatasetId, validationDatasetId, archived, deploymentStatus, links, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, commit=$commit, dateArchived=$dateArchived, dateCreated=$dateCreated, failingGoalCount=$failingGoalCount, mlModelId=$mlModelId, passingGoalCount=$passingGoalCount, bodyProjectId=$bodyProjectId, status=$status, statusMessage=$statusMessage, storageUri=$storageUri, totalGoalCount=$totalGoalCount, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, archived=$archived, deploymentStatus=$deploymentStatus, links=$links, additionalProperties=$additionalProperties}" + } + + /** The details of a commit (project version). */ + class Commit + private constructor( + private val id: JsonField, + private val authorId: JsonField, + private val fileSize: JsonField, + private val message: JsonField, + private val mlModelId: JsonField, + private val storageUri: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val dateCreated: JsonField, + private val gitCommitRef: JsonField, + private val gitCommitSha: JsonField, + private val gitCommitUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("authorId") + @ExcludeMissing + authorId: JsonField = JsonMissing.of(), + @JsonProperty("fileSize") @ExcludeMissing fileSize: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") + @ExcludeMissing + mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitRef") + @ExcludeMissing + gitCommitRef: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitSha") + @ExcludeMissing + gitCommitSha: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitUrl") + @ExcludeMissing + gitCommitUrl: JsonField = JsonMissing.of(), + ) : this( + id, + authorId, + fileSize, + message, + mlModelId, + storageUri, + trainingDatasetId, + validationDatasetId, + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + mutableMapOf(), + ) + + /** + * The commit id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The author id of the commit. + * + * @throws OpenlayerInvalidDataException 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 authorId(): String = authorId.getRequired("authorId") + + /** + * The size of the commit bundle in bytes. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fileSize(): Optional = fileSize.getOptional("fileSize") + + /** + * The commit message. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = + trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * The commit creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateCreated(): Optional = dateCreated.getOptional("dateCreated") + + /** + * The ref of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitRef(): Optional = gitCommitRef.getOptional("gitCommitRef") + + /** + * The SHA of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitSha(): Optional = gitCommitSha.getOptional("gitCommitSha") + + /** + * The URL of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitUrl(): Optional = gitCommitUrl.getOptional("gitCommitUrl") + + /** + * 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 [authorId]. + * + * Unlike [authorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("authorId") @ExcludeMissing fun _authorId(): JsonField = authorId + + /** + * Returns the raw JSON value of [fileSize]. + * + * Unlike [fileSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileSize") @ExcludeMissing fun _fileSize(): JsonField = fileSize + + /** + * 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 [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") + @ExcludeMissing + fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [gitCommitRef]. + * + * Unlike [gitCommitRef], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitRef") + @ExcludeMissing + fun _gitCommitRef(): JsonField = gitCommitRef + + /** + * Returns the raw JSON value of [gitCommitSha]. + * + * Unlike [gitCommitSha], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitSha") + @ExcludeMissing + fun _gitCommitSha(): JsonField = gitCommitSha + + /** + * Returns the raw JSON value of [gitCommitUrl]. + * + * Unlike [gitCommitUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitUrl") + @ExcludeMissing + fun _gitCommitUrl(): JsonField = gitCommitUrl + + @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 [Commit]. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var authorId: JsonField? = null + private var fileSize: JsonField? = null + private var message: JsonField? = null + private var mlModelId: JsonField? = null + private var storageUri: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var dateCreated: JsonField = JsonMissing.of() + private var gitCommitRef: JsonField = JsonMissing.of() + private var gitCommitSha: JsonField = JsonMissing.of() + private var gitCommitUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + id = commit.id + authorId = commit.authorId + fileSize = commit.fileSize + message = commit.message + mlModelId = commit.mlModelId + storageUri = commit.storageUri + trainingDatasetId = commit.trainingDatasetId + validationDatasetId = commit.validationDatasetId + dateCreated = commit.dateCreated + gitCommitRef = commit.gitCommitRef + gitCommitSha = commit.gitCommitSha + gitCommitUrl = commit.gitCommitUrl + additionalProperties = commit.additionalProperties.toMutableMap() + } + + /** The commit id. */ + 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 } + + /** The author id of the commit. */ + fun authorId(authorId: String) = authorId(JsonField.of(authorId)) + + /** + * Sets [Builder.authorId] to an arbitrary JSON value. + * + * You should usually call [Builder.authorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorId(authorId: JsonField) = apply { this.authorId = authorId } + + /** The size of the commit bundle in bytes. */ + fun fileSize(fileSize: Long?) = fileSize(JsonField.ofNullable(fileSize)) + + /** + * Alias for [Builder.fileSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fileSize(fileSize: Long) = fileSize(fileSize as Long?) + + /** Alias for calling [Builder.fileSize] with `fileSize.orElse(null)`. */ + fun fileSize(fileSize: Optional) = fileSize(fileSize.getOrNull()) + + /** + * Sets [Builder.fileSize] to an arbitrary JSON value. + * + * You should usually call [Builder.fileSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } + + /** The commit message. */ + 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 } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** + * Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. + */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with + * `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The commit creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The ref of the corresponding git commit. */ + fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) + + /** + * Sets [Builder.gitCommitRef] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitRef] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitRef(gitCommitRef: JsonField) = apply { + this.gitCommitRef = gitCommitRef + } + + /** The SHA of the corresponding git commit. */ + fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) + + /** + * Sets [Builder.gitCommitSha] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitSha] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitSha(gitCommitSha: JsonField) = apply { + this.gitCommitSha = gitCommitSha + } + + /** The URL of the corresponding git commit. */ + fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) + + /** + * Sets [Builder.gitCommitUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitUrl(gitCommitUrl: JsonField) = apply { + this.gitCommitUrl = gitCommitUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Commit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Commit = + Commit( + checkRequired("id", id), + checkRequired("authorId", authorId), + checkRequired("fileSize", fileSize), + checkRequired("message", message), + checkRequired("mlModelId", mlModelId), + checkRequired("storageUri", storageUri), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Commit = apply { + if (validated) { + return@apply + } + + id() + authorId() + fileSize() + message() + mlModelId() + storageUri() + trainingDatasetId() + validationDatasetId() + dateCreated() + gitCommitRef() + gitCommitSha() + gitCommitUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && storageUri == other.storageUri && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && dateCreated == other.dateCreated && gitCommitRef == other.gitCommitRef && gitCommitSha == other.gitCommitSha && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, authorId, fileSize, message, mlModelId, storageUri, trainingDatasetId, validationDatasetId, dateCreated, gitCommitRef, gitCommitSha, gitCommitUrl, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Commit{id=$id, authorId=$authorId, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, storageUri=$storageUri, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, dateCreated=$dateCreated, gitCommitRef=$gitCommitRef, gitCommitSha=$gitCommitSha, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CommitCreateParams && pathProjectId == other.pathProjectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(pathProjectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "CommitCreateParams{pathProjectId=$pathProjectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt new file mode 100644 index 00000000..5e56889b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt @@ -0,0 +1,1813 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CommitCreateResponse +private constructor( + private val id: JsonField, + private val commit: JsonField, + private val dateArchived: JsonField, + private val dateCreated: JsonField, + private val failingGoalCount: JsonField, + private val mlModelId: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val storageUri: JsonField, + private val totalGoalCount: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val archived: JsonField, + private val deploymentStatus: JsonField, + private val links: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), + @JsonProperty("dateArchived") + @ExcludeMissing + dateArchived: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") @ExcludeMissing mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("archived") @ExcludeMissing archived: JsonField = JsonMissing.of(), + @JsonProperty("deploymentStatus") + @ExcludeMissing + deploymentStatus: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + ) : this( + id, + commit, + dateArchived, + dateCreated, + failingGoalCount, + mlModelId, + passingGoalCount, + projectId, + status, + statusMessage, + storageUri, + totalGoalCount, + trainingDatasetId, + validationDatasetId, + archived, + deploymentStatus, + links, + mutableMapOf(), + ) + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The details of a commit (project version). + * + * @throws OpenlayerInvalidDataException 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 commit(): Commit = commit.getRequired("commit") + + /** + * The commit archive date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateArchived(): Optional = dateArchived.getOptional("dateArchived") + + /** + * The project version (commit) creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The number of tests that are failing for the commit. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The number of tests that are passing for the commit. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The commit status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The total number of tests for the commit. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * Whether the commit is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun archived(): Optional = archived.getOptional("archived") + + /** + * The deployment status associated with the commit's model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deploymentStatus(): Optional = deploymentStatus.getOptional("deploymentStatus") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun links(): Optional = links.getOptional("links") + + /** + * 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 [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun _dateArchived(): JsonField = dateArchived + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") @ExcludeMissing fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("archived") @ExcludeMissing fun _archived(): JsonField = archived + + /** + * Returns the raw JSON value of [deploymentStatus]. + * + * Unlike [deploymentStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deploymentStatus") + @ExcludeMissing + fun _deploymentStatus(): JsonField = deploymentStatus + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + @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 [CommitCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var commit: JsonField? = null + private var dateArchived: JsonField? = null + private var dateCreated: JsonField? = null + private var failingGoalCount: JsonField? = null + private var mlModelId: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var storageUri: JsonField? = null + private var totalGoalCount: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var archived: JsonField = JsonMissing.of() + private var deploymentStatus: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitCreateResponse: CommitCreateResponse) = apply { + id = commitCreateResponse.id + commit = commitCreateResponse.commit + dateArchived = commitCreateResponse.dateArchived + dateCreated = commitCreateResponse.dateCreated + failingGoalCount = commitCreateResponse.failingGoalCount + mlModelId = commitCreateResponse.mlModelId + passingGoalCount = commitCreateResponse.passingGoalCount + projectId = commitCreateResponse.projectId + status = commitCreateResponse.status + statusMessage = commitCreateResponse.statusMessage + storageUri = commitCreateResponse.storageUri + totalGoalCount = commitCreateResponse.totalGoalCount + trainingDatasetId = commitCreateResponse.trainingDatasetId + validationDatasetId = commitCreateResponse.validationDatasetId + archived = commitCreateResponse.archived + deploymentStatus = commitCreateResponse.deploymentStatus + links = commitCreateResponse.links + additionalProperties = commitCreateResponse.additionalProperties.toMutableMap() + } + + /** The project version (commit) id. */ + 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 } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = commit(JsonField.of(commit)) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [Commit] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** The commit archive date. */ + fun dateArchived(dateArchived: OffsetDateTime?) = + dateArchived(JsonField.ofNullable(dateArchived)) + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The project version (commit) creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The commit status message. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The total number of tests for the commit. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean?) = archived(JsonField.ofNullable(archived)) + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = + deploymentStatus(JsonField.of(deploymentStatus)) + + /** + * Sets [Builder.deploymentStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentStatus] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deploymentStatus(deploymentStatus: JsonField) = apply { + this.deploymentStatus = deploymentStatus + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CommitCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitCreateResponse = + CommitCreateResponse( + checkRequired("id", id), + checkRequired("commit", commit), + checkRequired("dateArchived", dateArchived), + checkRequired("dateCreated", dateCreated), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("mlModelId", mlModelId), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("storageUri", storageUri), + checkRequired("totalGoalCount", totalGoalCount), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + archived, + deploymentStatus, + links, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommitCreateResponse = apply { + if (validated) { + return@apply + } + + id() + commit().validate() + dateArchived() + dateCreated() + failingGoalCount() + mlModelId() + passingGoalCount() + projectId() + status().validate() + statusMessage() + storageUri() + totalGoalCount() + trainingDatasetId() + validationDatasetId() + archived() + deploymentStatus() + links().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + /** The details of a commit (project version). */ + class Commit + private constructor( + private val id: JsonField, + private val authorId: JsonField, + private val fileSize: JsonField, + private val message: JsonField, + private val mlModelId: JsonField, + private val storageUri: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val dateCreated: JsonField, + private val gitCommitRef: JsonField, + private val gitCommitSha: JsonField, + private val gitCommitUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("authorId") + @ExcludeMissing + authorId: JsonField = JsonMissing.of(), + @JsonProperty("fileSize") @ExcludeMissing fileSize: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") + @ExcludeMissing + mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitRef") + @ExcludeMissing + gitCommitRef: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitSha") + @ExcludeMissing + gitCommitSha: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitUrl") + @ExcludeMissing + gitCommitUrl: JsonField = JsonMissing.of(), + ) : this( + id, + authorId, + fileSize, + message, + mlModelId, + storageUri, + trainingDatasetId, + validationDatasetId, + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + mutableMapOf(), + ) + + /** + * The commit id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The author id of the commit. + * + * @throws OpenlayerInvalidDataException 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 authorId(): String = authorId.getRequired("authorId") + + /** + * The size of the commit bundle in bytes. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fileSize(): Optional = fileSize.getOptional("fileSize") + + /** + * The commit message. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = + trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * The commit creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateCreated(): Optional = dateCreated.getOptional("dateCreated") + + /** + * The ref of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitRef(): Optional = gitCommitRef.getOptional("gitCommitRef") + + /** + * The SHA of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitSha(): Optional = gitCommitSha.getOptional("gitCommitSha") + + /** + * The URL of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitCommitUrl(): Optional = gitCommitUrl.getOptional("gitCommitUrl") + + /** + * 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 [authorId]. + * + * Unlike [authorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("authorId") @ExcludeMissing fun _authorId(): JsonField = authorId + + /** + * Returns the raw JSON value of [fileSize]. + * + * Unlike [fileSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fileSize") @ExcludeMissing fun _fileSize(): JsonField = fileSize + + /** + * 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 [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") + @ExcludeMissing + fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [gitCommitRef]. + * + * Unlike [gitCommitRef], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitRef") + @ExcludeMissing + fun _gitCommitRef(): JsonField = gitCommitRef + + /** + * Returns the raw JSON value of [gitCommitSha]. + * + * Unlike [gitCommitSha], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitSha") + @ExcludeMissing + fun _gitCommitSha(): JsonField = gitCommitSha + + /** + * Returns the raw JSON value of [gitCommitUrl]. + * + * Unlike [gitCommitUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitUrl") + @ExcludeMissing + fun _gitCommitUrl(): JsonField = gitCommitUrl + + @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 [Commit]. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var authorId: JsonField? = null + private var fileSize: JsonField? = null + private var message: JsonField? = null + private var mlModelId: JsonField? = null + private var storageUri: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var dateCreated: JsonField = JsonMissing.of() + private var gitCommitRef: JsonField = JsonMissing.of() + private var gitCommitSha: JsonField = JsonMissing.of() + private var gitCommitUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + id = commit.id + authorId = commit.authorId + fileSize = commit.fileSize + message = commit.message + mlModelId = commit.mlModelId + storageUri = commit.storageUri + trainingDatasetId = commit.trainingDatasetId + validationDatasetId = commit.validationDatasetId + dateCreated = commit.dateCreated + gitCommitRef = commit.gitCommitRef + gitCommitSha = commit.gitCommitSha + gitCommitUrl = commit.gitCommitUrl + additionalProperties = commit.additionalProperties.toMutableMap() + } + + /** The commit id. */ + 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 } + + /** The author id of the commit. */ + fun authorId(authorId: String) = authorId(JsonField.of(authorId)) + + /** + * Sets [Builder.authorId] to an arbitrary JSON value. + * + * You should usually call [Builder.authorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorId(authorId: JsonField) = apply { this.authorId = authorId } + + /** The size of the commit bundle in bytes. */ + fun fileSize(fileSize: Long?) = fileSize(JsonField.ofNullable(fileSize)) + + /** + * Alias for [Builder.fileSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fileSize(fileSize: Long) = fileSize(fileSize as Long?) + + /** Alias for calling [Builder.fileSize] with `fileSize.orElse(null)`. */ + fun fileSize(fileSize: Optional) = fileSize(fileSize.getOrNull()) + + /** + * Sets [Builder.fileSize] to an arbitrary JSON value. + * + * You should usually call [Builder.fileSize] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } + + /** The commit message. */ + 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 } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** + * Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. + */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with + * `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The commit creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The ref of the corresponding git commit. */ + fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) + + /** + * Sets [Builder.gitCommitRef] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitRef] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitRef(gitCommitRef: JsonField) = apply { + this.gitCommitRef = gitCommitRef + } + + /** The SHA of the corresponding git commit. */ + fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) + + /** + * Sets [Builder.gitCommitSha] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitSha] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitSha(gitCommitSha: JsonField) = apply { + this.gitCommitSha = gitCommitSha + } + + /** The URL of the corresponding git commit. */ + fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) + + /** + * Sets [Builder.gitCommitUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitCommitUrl(gitCommitUrl: JsonField) = apply { + this.gitCommitUrl = gitCommitUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Commit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Commit = + Commit( + checkRequired("id", id), + checkRequired("authorId", authorId), + checkRequired("fileSize", fileSize), + checkRequired("message", message), + checkRequired("mlModelId", mlModelId), + checkRequired("storageUri", storageUri), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Commit = apply { + if (validated) { + return@apply + } + + id() + authorId() + fileSize() + message() + mlModelId() + storageUri() + trainingDatasetId() + validationDatasetId() + dateCreated() + gitCommitRef() + gitCommitSha() + gitCommitUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && storageUri == other.storageUri && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && dateCreated == other.dateCreated && gitCommitRef == other.gitCommitRef && gitCommitSha == other.gitCommitSha && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, authorId, fileSize, message, mlModelId, storageUri, trainingDatasetId, validationDatasetId, dateCreated, gitCommitRef, gitCommitSha, gitCommitUrl, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Commit{id=$id, authorId=$authorId, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, storageUri=$storageUri, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, dateCreated=$dateCreated, gitCommitRef=$gitCommitRef, gitCommitSha=$gitCommitSha, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CommitCreateResponse && id == other.id && commit == other.commit && dateArchived == other.dateArchived && dateCreated == other.dateCreated && failingGoalCount == other.failingGoalCount && mlModelId == other.mlModelId && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && storageUri == other.storageUri && totalGoalCount == other.totalGoalCount && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && archived == other.archived && deploymentStatus == other.deploymentStatus && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, commit, dateArchived, dateCreated, failingGoalCount, mlModelId, passingGoalCount, projectId, status, statusMessage, storageUri, totalGoalCount, trainingDatasetId, validationDatasetId, archived, deploymentStatus, links, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitCreateResponse{id=$id, commit=$commit, dateArchived=$dateArchived, dateCreated=$dateCreated, failingGoalCount=$failingGoalCount, mlModelId=$mlModelId, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, storageUri=$storageUri, totalGoalCount=$totalGoalCount, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, archived=$archived, deploymentStatus=$deploymentStatus, links=$links, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListParams.kt similarity index 62% rename from openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineListParams.kt rename to openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListParams.kt index 6aa853f7..7c0fd921 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectInferencePipelineListParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListParams.kt @@ -1,93 +1,97 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.projects.commits -import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull -class ProjectInferencePipelineListParams -constructor( +/** List the commits (project versions) in a project. */ +class CommitListParams +private constructor( private val projectId: String, - private val name: String?, private val page: Long?, private val perPage: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, -) { +) : Params { fun projectId(): String = projectId - fun name(): Optional = Optional.ofNullable(name) - + /** The page to return in a paginated query. */ fun page(): Optional = Optional.ofNullable(page) + /** Maximum number of items to return per page. */ fun perPage(): Optional = Optional.ofNullable(perPage) fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders - - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.name?.let { queryParams.put("name", listOf(it.toString())) } - this.page?.let { queryParams.put("page", listOf(it.toString())) } - this.perPage?.let { queryParams.put("perPage", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } - - fun getPathParam(index: Int): String { - return when (index) { - 0 -> projectId - else -> "" - } - } - fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [CommitListParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ @JvmStatic fun builder() = Builder() } - @NoAutoDetect - class Builder { + /** A builder for [CommitListParams]. */ + class Builder internal constructor() { private var projectId: String? = null - private var name: String? = null private var page: Long? = null private var perPage: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(projectInferencePipelineListParams: ProjectInferencePipelineListParams) = - apply { - projectId = projectInferencePipelineListParams.projectId - name = projectInferencePipelineListParams.name - page = projectInferencePipelineListParams.page - perPage = projectInferencePipelineListParams.perPage - additionalHeaders = projectInferencePipelineListParams.additionalHeaders.toBuilder() - additionalQueryParams = - projectInferencePipelineListParams.additionalQueryParams.toBuilder() - } + internal fun from(commitListParams: CommitListParams) = apply { + projectId = commitListParams.projectId + page = commitListParams.page + perPage = commitListParams.perPage + additionalHeaders = commitListParams.additionalHeaders.toBuilder() + additionalQueryParams = commitListParams.additionalQueryParams.toBuilder() + } fun projectId(projectId: String) = apply { this.projectId = projectId } - /** Filter list of items by name. */ - fun name(name: String) = apply { this.name = name } - /** The page to return in a paginated query. */ - fun page(page: Long) = apply { this.page = page } + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) /** Maximum number of items to return per page. */ - fun perPage(perPage: Long) = apply { this.perPage = perPage } + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -187,10 +191,21 @@ constructor( additionalQueryParams.removeAll(keys) } - fun build(): ProjectInferencePipelineListParams = - ProjectInferencePipelineListParams( - checkNotNull(projectId) { "`projectId` is required but was not set" }, - name, + /** + * Returns an immutable instance of [CommitListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CommitListParams = + CommitListParams( + checkRequired("projectId", projectId), page, perPage, additionalHeaders.build(), @@ -198,16 +213,33 @@ constructor( ) } + fun _pathParam(index: Int): String = + when (index) { + 0 -> projectId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ProjectInferencePipelineListParams && projectId == other.projectId && name == other.name && page == other.page && perPage == other.perPage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + return /* spotless:off */ other is CommitListParams && projectId == other.projectId && page == other.page && perPage == other.perPage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, name, page, perPage, additionalHeaders, additionalQueryParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, page, perPage, additionalHeaders, additionalQueryParams) /* spotless:on */ override fun toString() = - "ProjectInferencePipelineListParams{projectId=$projectId, name=$name, page=$page, perPage=$perPage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CommitListParams{projectId=$projectId, page=$page, perPage=$perPage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt new file mode 100644 index 00000000..34423156 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt @@ -0,0 +1,2031 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CommitListResponse +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 [CommitListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CommitListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitListResponse: CommitListResponse) = apply { + items = commitListResponse.items.map { it.toMutableList() } + additionalProperties = commitListResponse.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 [CommitListResponse]. + * + * 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(): CommitListResponse = + CommitListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CommitListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + class Item + private constructor( + private val id: JsonField, + private val commit: JsonField, + private val dateArchived: JsonField, + private val dateCreated: JsonField, + private val failingGoalCount: JsonField, + private val mlModelId: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val storageUri: JsonField, + private val totalGoalCount: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val archived: JsonField, + private val deploymentStatus: JsonField, + private val links: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("commit") @ExcludeMissing commit: JsonField = JsonMissing.of(), + @JsonProperty("dateArchived") + @ExcludeMissing + dateArchived: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") + @ExcludeMissing + mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("archived") + @ExcludeMissing + archived: JsonField = JsonMissing.of(), + @JsonProperty("deploymentStatus") + @ExcludeMissing + deploymentStatus: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + ) : this( + id, + commit, + dateArchived, + dateCreated, + failingGoalCount, + mlModelId, + passingGoalCount, + projectId, + status, + statusMessage, + storageUri, + totalGoalCount, + trainingDatasetId, + validationDatasetId, + archived, + deploymentStatus, + links, + mutableMapOf(), + ) + + /** + * The project version (commit) id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The details of a commit (project version). + * + * @throws OpenlayerInvalidDataException 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 commit(): Commit = commit.getRequired("commit") + + /** + * The commit archive date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateArchived(): Optional = dateArchived.getOptional("dateArchived") + + /** + * The project version (commit) creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The number of tests that are failing for the commit. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The number of tests that are passing for the commit. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The commit status message. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The total number of tests for the commit. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = + trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * Whether the commit is archived. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun archived(): Optional = archived.getOptional("archived") + + /** + * The deployment status associated with the commit's model. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deploymentStatus(): Optional = deploymentStatus.getOptional("deploymentStatus") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun links(): Optional = links.getOptional("links") + + /** + * 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 [commit]. + * + * Unlike [commit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("commit") @ExcludeMissing fun _commit(): JsonField = commit + + /** + * Returns the raw JSON value of [dateArchived]. + * + * Unlike [dateArchived], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun _dateArchived(): JsonField = dateArchived + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") + @ExcludeMissing + fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [archived]. + * + * Unlike [archived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("archived") @ExcludeMissing fun _archived(): JsonField = archived + + /** + * Returns the raw JSON value of [deploymentStatus]. + * + * Unlike [deploymentStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("deploymentStatus") + @ExcludeMissing + fun _deploymentStatus(): JsonField = deploymentStatus + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + @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() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var commit: JsonField? = null + private var dateArchived: JsonField? = null + private var dateCreated: JsonField? = null + private var failingGoalCount: JsonField? = null + private var mlModelId: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var storageUri: JsonField? = null + private var totalGoalCount: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var archived: JsonField = JsonMissing.of() + private var deploymentStatus: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + commit = item.commit + dateArchived = item.dateArchived + dateCreated = item.dateCreated + failingGoalCount = item.failingGoalCount + mlModelId = item.mlModelId + passingGoalCount = item.passingGoalCount + projectId = item.projectId + status = item.status + statusMessage = item.statusMessage + storageUri = item.storageUri + totalGoalCount = item.totalGoalCount + trainingDatasetId = item.trainingDatasetId + validationDatasetId = item.validationDatasetId + archived = item.archived + deploymentStatus = item.deploymentStatus + links = item.links + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The project version (commit) id. */ + 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 } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = commit(JsonField.of(commit)) + + /** + * Sets [Builder.commit] to an arbitrary JSON value. + * + * You should usually call [Builder.commit] with a well-typed [Commit] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** The commit archive date. */ + fun dateArchived(dateArchived: OffsetDateTime?) = + dateArchived(JsonField.ofNullable(dateArchived)) + + /** Alias for calling [Builder.dateArchived] with `dateArchived.orElse(null)`. */ + fun dateArchived(dateArchived: Optional) = + dateArchived(dateArchived.getOrNull()) + + /** + * Sets [Builder.dateArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateArchived] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The project version (commit) creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The commit status message. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The total number of tests for the commit. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** + * Alias for calling [Builder.trainingDatasetId] with `trainingDatasetId.orElse(null)`. + */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with + * `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean?) = archived(JsonField.ofNullable(archived)) + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + /** + * Sets [Builder.archived] to an arbitrary JSON value. + * + * You should usually call [Builder.archived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = + deploymentStatus(JsonField.of(deploymentStatus)) + + /** + * Sets [Builder.deploymentStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.deploymentStatus] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deploymentStatus(deploymentStatus: JsonField) = apply { + this.deploymentStatus = deploymentStatus + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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() + * .commit() + * .dateArchived() + * .dateCreated() + * .failingGoalCount() + * .mlModelId() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .storageUri() + * .totalGoalCount() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("commit", commit), + checkRequired("dateArchived", dateArchived), + checkRequired("dateCreated", dateCreated), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("mlModelId", mlModelId), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("storageUri", storageUri), + checkRequired("totalGoalCount", totalGoalCount), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + archived, + deploymentStatus, + links, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + commit().validate() + dateArchived() + dateCreated() + failingGoalCount() + mlModelId() + passingGoalCount() + projectId() + status().validate() + statusMessage() + storageUri() + totalGoalCount() + trainingDatasetId() + validationDatasetId() + archived() + deploymentStatus() + links().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + /** The details of a commit (project version). */ + class Commit + private constructor( + private val id: JsonField, + private val authorId: JsonField, + private val fileSize: JsonField, + private val message: JsonField, + private val mlModelId: JsonField, + private val storageUri: JsonField, + private val trainingDatasetId: JsonField, + private val validationDatasetId: JsonField, + private val dateCreated: JsonField, + private val gitCommitRef: JsonField, + private val gitCommitSha: JsonField, + private val gitCommitUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("authorId") + @ExcludeMissing + authorId: JsonField = JsonMissing.of(), + @JsonProperty("fileSize") + @ExcludeMissing + fileSize: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("mlModelId") + @ExcludeMissing + mlModelId: JsonField = JsonMissing.of(), + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("trainingDatasetId") + @ExcludeMissing + trainingDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("validationDatasetId") + @ExcludeMissing + validationDatasetId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitRef") + @ExcludeMissing + gitCommitRef: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitSha") + @ExcludeMissing + gitCommitSha: JsonField = JsonMissing.of(), + @JsonProperty("gitCommitUrl") + @ExcludeMissing + gitCommitUrl: JsonField = JsonMissing.of(), + ) : this( + id, + authorId, + fileSize, + message, + mlModelId, + storageUri, + trainingDatasetId, + validationDatasetId, + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + mutableMapOf(), + ) + + /** + * The commit id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The author id of the commit. + * + * @throws OpenlayerInvalidDataException 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 authorId(): String = authorId.getRequired("authorId") + + /** + * The size of the commit bundle in bytes. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fileSize(): Optional = fileSize.getOptional("fileSize") + + /** + * The commit message. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The model id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun mlModelId(): Optional = mlModelId.getOptional("mlModelId") + + /** + * The storage URI where the commit bundle is stored. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The training dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun trainingDatasetId(): Optional = + trainingDatasetId.getOptional("trainingDatasetId") + + /** + * The validation dataset id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun validationDatasetId(): Optional = + validationDatasetId.getOptional("validationDatasetId") + + /** + * The commit creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dateCreated(): Optional = dateCreated.getOptional("dateCreated") + + /** + * The ref of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gitCommitRef(): Optional = gitCommitRef.getOptional("gitCommitRef") + + /** + * The SHA of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gitCommitSha(): Optional = gitCommitSha.getOptional("gitCommitSha") + + /** + * The URL of the corresponding git commit. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gitCommitUrl(): Optional = gitCommitUrl.getOptional("gitCommitUrl") + + /** + * 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 [authorId]. + * + * Unlike [authorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorId") @ExcludeMissing fun _authorId(): JsonField = authorId + + /** + * Returns the raw JSON value of [fileSize]. + * + * Unlike [fileSize], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fileSize") @ExcludeMissing fun _fileSize(): JsonField = fileSize + + /** + * 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 [mlModelId]. + * + * Unlike [mlModelId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mlModelId") + @ExcludeMissing + fun _mlModelId(): JsonField = mlModelId + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("storageUri") + @ExcludeMissing + fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [trainingDatasetId]. + * + * Unlike [trainingDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId(): JsonField = trainingDatasetId + + /** + * Returns the raw JSON value of [validationDatasetId]. + * + * Unlike [validationDatasetId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId(): JsonField = validationDatasetId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [gitCommitRef]. + * + * Unlike [gitCommitRef], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitRef") + @ExcludeMissing + fun _gitCommitRef(): JsonField = gitCommitRef + + /** + * Returns the raw JSON value of [gitCommitSha]. + * + * Unlike [gitCommitSha], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitSha") + @ExcludeMissing + fun _gitCommitSha(): JsonField = gitCommitSha + + /** + * Returns the raw JSON value of [gitCommitUrl]. + * + * Unlike [gitCommitUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitCommitUrl") + @ExcludeMissing + fun _gitCommitUrl(): JsonField = gitCommitUrl + + @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 [Commit]. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Commit]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var authorId: JsonField? = null + private var fileSize: JsonField? = null + private var message: JsonField? = null + private var mlModelId: JsonField? = null + private var storageUri: JsonField? = null + private var trainingDatasetId: JsonField? = null + private var validationDatasetId: JsonField? = null + private var dateCreated: JsonField = JsonMissing.of() + private var gitCommitRef: JsonField = JsonMissing.of() + private var gitCommitSha: JsonField = JsonMissing.of() + private var gitCommitUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + id = commit.id + authorId = commit.authorId + fileSize = commit.fileSize + message = commit.message + mlModelId = commit.mlModelId + storageUri = commit.storageUri + trainingDatasetId = commit.trainingDatasetId + validationDatasetId = commit.validationDatasetId + dateCreated = commit.dateCreated + gitCommitRef = commit.gitCommitRef + gitCommitSha = commit.gitCommitSha + gitCommitUrl = commit.gitCommitUrl + additionalProperties = commit.additionalProperties.toMutableMap() + } + + /** The commit id. */ + 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 } + + /** The author id of the commit. */ + fun authorId(authorId: String) = authorId(JsonField.of(authorId)) + + /** + * Sets [Builder.authorId] to an arbitrary JSON value. + * + * You should usually call [Builder.authorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun authorId(authorId: JsonField) = apply { this.authorId = authorId } + + /** The size of the commit bundle in bytes. */ + fun fileSize(fileSize: Long?) = fileSize(JsonField.ofNullable(fileSize)) + + /** + * Alias for [Builder.fileSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun fileSize(fileSize: Long) = fileSize(fileSize as Long?) + + /** Alias for calling [Builder.fileSize] with `fileSize.orElse(null)`. */ + fun fileSize(fileSize: Optional) = fileSize(fileSize.getOrNull()) + + /** + * Sets [Builder.fileSize] to an arbitrary JSON value. + * + * You should usually call [Builder.fileSize] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } + + /** The commit message. */ + 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 } + + /** The model id. */ + fun mlModelId(mlModelId: String?) = mlModelId(JsonField.ofNullable(mlModelId)) + + /** Alias for calling [Builder.mlModelId] with `mlModelId.orElse(null)`. */ + fun mlModelId(mlModelId: Optional) = mlModelId(mlModelId.getOrNull()) + + /** + * Sets [Builder.mlModelId] to an arbitrary JSON value. + * + * You should usually call [Builder.mlModelId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun storageUri(storageUri: JsonField) = apply { + this.storageUri = storageUri + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String?) = + trainingDatasetId(JsonField.ofNullable(trainingDatasetId)) + + /** + * Alias for calling [Builder.trainingDatasetId] with + * `trainingDatasetId.orElse(null)`. + */ + fun trainingDatasetId(trainingDatasetId: Optional) = + trainingDatasetId(trainingDatasetId.getOrNull()) + + /** + * Sets [Builder.trainingDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.trainingDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String?) = + validationDatasetId(JsonField.ofNullable(validationDatasetId)) + + /** + * Alias for calling [Builder.validationDatasetId] with + * `validationDatasetId.orElse(null)`. + */ + fun validationDatasetId(validationDatasetId: Optional) = + validationDatasetId(validationDatasetId.getOrNull()) + + /** + * Sets [Builder.validationDatasetId] to an arbitrary JSON value. + * + * You should usually call [Builder.validationDatasetId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The commit creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The ref of the corresponding git commit. */ + fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) + + /** + * Sets [Builder.gitCommitRef] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitRef] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitCommitRef(gitCommitRef: JsonField) = apply { + this.gitCommitRef = gitCommitRef + } + + /** The SHA of the corresponding git commit. */ + fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) + + /** + * Sets [Builder.gitCommitSha] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitSha] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitCommitSha(gitCommitSha: JsonField) = apply { + this.gitCommitSha = gitCommitSha + } + + /** The URL of the corresponding git commit. */ + fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) + + /** + * Sets [Builder.gitCommitUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.gitCommitUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitCommitUrl(gitCommitUrl: JsonField) = apply { + this.gitCommitUrl = gitCommitUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Commit]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .authorId() + * .fileSize() + * .message() + * .mlModelId() + * .storageUri() + * .trainingDatasetId() + * .validationDatasetId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Commit = + Commit( + checkRequired("id", id), + checkRequired("authorId", authorId), + checkRequired("fileSize", fileSize), + checkRequired("message", message), + checkRequired("mlModelId", mlModelId), + checkRequired("storageUri", storageUri), + checkRequired("trainingDatasetId", trainingDatasetId), + checkRequired("validationDatasetId", validationDatasetId), + dateCreated, + gitCommitRef, + gitCommitSha, + gitCommitUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Commit = apply { + if (validated) { + return@apply + } + + id() + authorId() + fileSize() + message() + mlModelId() + storageUri() + trainingDatasetId() + validationDatasetId() + dateCreated() + gitCommitRef() + gitCommitSha() + gitCommitUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Commit && id == other.id && authorId == other.authorId && fileSize == other.fileSize && message == other.message && mlModelId == other.mlModelId && storageUri == other.storageUri && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && dateCreated == other.dateCreated && gitCommitRef == other.gitCommitRef && gitCommitSha == other.gitCommitSha && gitCommitUrl == other.gitCommitUrl && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, authorId, fileSize, message, mlModelId, storageUri, trainingDatasetId, validationDatasetId, dateCreated, gitCommitRef, gitCommitSha, gitCommitUrl, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Commit{id=$id, authorId=$authorId, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, storageUri=$storageUri, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, dateCreated=$dateCreated, gitCommitRef=$gitCommitRef, gitCommitSha=$gitCommitSha, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** + * An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Item && id == other.id && commit == other.commit && dateArchived == other.dateArchived && dateCreated == other.dateCreated && failingGoalCount == other.failingGoalCount && mlModelId == other.mlModelId && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && storageUri == other.storageUri && totalGoalCount == other.totalGoalCount && trainingDatasetId == other.trainingDatasetId && validationDatasetId == other.validationDatasetId && archived == other.archived && deploymentStatus == other.deploymentStatus && links == other.links && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, commit, dateArchived, dateCreated, failingGoalCount, mlModelId, passingGoalCount, projectId, status, statusMessage, storageUri, totalGoalCount, trainingDatasetId, validationDatasetId, archived, deploymentStatus, links, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, commit=$commit, dateArchived=$dateArchived, dateCreated=$dateCreated, failingGoalCount=$failingGoalCount, mlModelId=$mlModelId, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, storageUri=$storageUri, totalGoalCount=$totalGoalCount, trainingDatasetId=$trainingDatasetId, validationDatasetId=$validationDatasetId, archived=$archived, deploymentStatus=$deploymentStatus, links=$links, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is CommitListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CommitListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt new file mode 100644 index 00000000..b5db2cb8 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt @@ -0,0 +1,5051 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create an inference pipeline in a project. */ +class InferencePipelineCreateParams +private constructor( + private val pathProjectId: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun pathProjectId(): String = pathProjectId + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException 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 = body.id() + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = body.dateCreated() + + /** + * The last test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastEvaluated(): Optional = body.dateLastEvaluated() + + /** + * The last data sample received date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastSampleReceived(): Optional = body.dateLastSampleReceived() + + /** + * The next test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateOfNextEvaluation(): Optional = body.dateOfNextEvaluation() + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = body.dateUpdated() + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * The number of tests failing. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = body.failingGoalCount() + + /** + * @throws OpenlayerInvalidDataException 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 links(): Links = body.links() + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException 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() + + /** + * The number of tests passing. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = body.passingGoalCount() + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 bodyProjectId(): String = body.bodyProjectId() + + /** + * The status of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = body.status() + + /** + * The status message of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = body.statusMessage() + + /** + * The total number of tests. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = body.totalGoalCount() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun project(): Optional = body.project() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspace(): Optional = body.workspace() + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = body.workspaceId() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField = body._id() + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dateCreated(): JsonField = body._dateCreated() + + /** + * Returns the raw JSON value of [dateLastEvaluated]. + * + * Unlike [dateLastEvaluated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _dateLastEvaluated(): JsonField = body._dateLastEvaluated() + + /** + * Returns the raw JSON value of [dateLastSampleReceived]. + * + * Unlike [dateLastSampleReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _dateLastSampleReceived(): JsonField = body._dateLastSampleReceived() + + /** + * Returns the raw JSON value of [dateOfNextEvaluation]. + * + * Unlike [dateOfNextEvaluation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _dateOfNextEvaluation(): JsonField = body._dateOfNextEvaluation() + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dateUpdated(): JsonField = body._dateUpdated() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _failingGoalCount(): JsonField = body._failingGoalCount() + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _links(): JsonField = body._links() + + /** + * 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 [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _passingGoalCount(): JsonField = body._passingGoalCount() + + /** + * Returns the raw JSON value of [bodyProjectId]. + * + * Unlike [bodyProjectId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bodyProjectId(): JsonField = body._bodyProjectId() + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _status(): JsonField = body._status() + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _statusMessage(): JsonField = body._statusMessage() + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _totalGoalCount(): JsonField = body._totalGoalCount() + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _project(): JsonField = body._project() + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _workspace(): JsonField = body._workspace() + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _workspaceId(): JsonField = body._workspaceId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InferencePipelineCreateParams]. + * + * The following fields are required: + * ```java + * .pathProjectId() + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineCreateParams]. */ + class Builder internal constructor() { + + private var pathProjectId: 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(inferencePipelineCreateParams: InferencePipelineCreateParams) = apply { + pathProjectId = inferencePipelineCreateParams.pathProjectId + body = inferencePipelineCreateParams.body.toBuilder() + additionalHeaders = inferencePipelineCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = inferencePipelineCreateParams.additionalQueryParams.toBuilder() + } + + fun pathProjectId(pathProjectId: String) = apply { this.pathProjectId = pathProjectId } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [id] + * - [dateCreated] + * - [dateLastEvaluated] + * - [dateLastSampleReceived] + * - [dateOfNextEvaluation] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The inference pipeline id. */ + fun id(id: String) = apply { body.id(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 { body.id(id) } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = apply { body.dateCreated(dateCreated) } + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + body.dateCreated(dateCreated) + } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime?) = apply { + body.dateLastEvaluated(dateLastEvaluated) + } + + /** Alias for calling [Builder.dateLastEvaluated] with `dateLastEvaluated.orElse(null)`. */ + fun dateLastEvaluated(dateLastEvaluated: Optional) = + dateLastEvaluated(dateLastEvaluated.getOrNull()) + + /** + * Sets [Builder.dateLastEvaluated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastEvaluated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + body.dateLastEvaluated(dateLastEvaluated) + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime?) = apply { + body.dateLastSampleReceived(dateLastSampleReceived) + } + + /** + * Alias for calling [Builder.dateLastSampleReceived] with + * `dateLastSampleReceived.orElse(null)`. + */ + fun dateLastSampleReceived(dateLastSampleReceived: Optional) = + dateLastSampleReceived(dateLastSampleReceived.getOrNull()) + + /** + * Sets [Builder.dateLastSampleReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastSampleReceived] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + body.dateLastSampleReceived(dateLastSampleReceived) + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime?) = apply { + body.dateOfNextEvaluation(dateOfNextEvaluation) + } + + /** + * Alias for calling [Builder.dateOfNextEvaluation] with + * `dateOfNextEvaluation.orElse(null)`. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: Optional) = + dateOfNextEvaluation(dateOfNextEvaluation.getOrNull()) + + /** + * Sets [Builder.dateOfNextEvaluation] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfNextEvaluation] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + body.dateOfNextEvaluation(dateOfNextEvaluation) + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = apply { body.dateUpdated(dateUpdated) } + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + body.dateUpdated(dateUpdated) + } + + /** The inference pipeline description. */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = apply { + body.failingGoalCount(failingGoalCount) + } + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + body.failingGoalCount(failingGoalCount) + } + + fun links(links: Links) = apply { body.links(links) } + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { body.links(links) } + + /** The inference pipeline name. */ + 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) } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = apply { + body.passingGoalCount(passingGoalCount) + } + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + body.passingGoalCount(passingGoalCount) + } + + /** The project id. */ + fun bodyProjectId(bodyProjectId: String) = apply { body.bodyProjectId(bodyProjectId) } + + /** + * Sets [Builder.bodyProjectId] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyProjectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun bodyProjectId(bodyProjectId: JsonField) = apply { + body.bodyProjectId(bodyProjectId) + } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = apply { body.status(status) } + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { body.status(status) } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String?) = apply { body.statusMessage(statusMessage) } + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + body.statusMessage(statusMessage) + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = apply { body.totalGoalCount(totalGoalCount) } + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + body.totalGoalCount(totalGoalCount) + } + + fun project(project: Project?) = apply { body.project(project) } + + /** Alias for calling [Builder.project] with `project.orElse(null)`. */ + fun project(project: Optional) = project(project.getOrNull()) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [Project] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun project(project: JsonField) = apply { body.project(project) } + + fun workspace(workspace: Workspace?) = apply { body.workspace(workspace) } + + /** Alias for calling [Builder.workspace] with `workspace.orElse(null)`. */ + fun workspace(workspace: Optional) = workspace(workspace.getOrNull()) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspace(workspace: JsonField) = apply { body.workspace(workspace) } + + /** The workspace id. */ + fun workspaceId(workspaceId: String) = apply { body.workspaceId(workspaceId) } + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { body.workspaceId(workspaceId) } + + 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 [InferencePipelineCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .pathProjectId() + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InferencePipelineCreateParams = + InferencePipelineCreateParams( + checkRequired("pathProjectId", pathProjectId), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> pathProjectId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateLastEvaluated: JsonField, + private val dateLastSampleReceived: JsonField, + private val dateOfNextEvaluation: JsonField, + private val dateUpdated: JsonField, + private val description: JsonField, + private val failingGoalCount: JsonField, + private val links: JsonField, + private val name: JsonField, + private val passingGoalCount: JsonField, + private val bodyProjectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val totalGoalCount: JsonField, + private val project: JsonField, + private val workspace: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + dateLastEvaluated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + dateLastSampleReceived: JsonField = JsonMissing.of(), + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + dateOfNextEvaluation: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + bodyProjectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("project") @ExcludeMissing project: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateLastEvaluated, + dateLastSampleReceived, + dateOfNextEvaluation, + dateUpdated, + description, + failingGoalCount, + links, + name, + passingGoalCount, + bodyProjectId, + status, + statusMessage, + totalGoalCount, + project, + workspace, + workspaceId, + mutableMapOf(), + ) + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateLastEvaluated(): Optional = + dateLastEvaluated.getOptional("dateLastEvaluated") + + /** + * The last data sample received date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateLastSampleReceived(): Optional = + dateLastSampleReceived.getOptional("dateLastSampleReceived") + + /** + * The next test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateOfNextEvaluation(): Optional = + dateOfNextEvaluation.getOptional("dateOfNextEvaluation") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The number of tests failing. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of tests passing. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 bodyProjectId(): String = bodyProjectId.getRequired("projectId") + + /** + * The status of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The total number of tests. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspace(): Optional = workspace.getOptional("workspace") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateLastEvaluated]. + * + * Unlike [dateLastEvaluated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + fun _dateLastEvaluated(): JsonField = dateLastEvaluated + + /** + * Returns the raw JSON value of [dateLastSampleReceived]. + * + * Unlike [dateLastSampleReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun _dateLastSampleReceived(): JsonField = dateLastSampleReceived + + /** + * Returns the raw JSON value of [dateOfNextEvaluation]. + * + * Unlike [dateOfNextEvaluation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun _dateOfNextEvaluation(): JsonField = dateOfNextEvaluation + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * 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 [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [bodyProjectId]. + * + * Unlike [bodyProjectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _bodyProjectId(): JsonField = bodyProjectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") + @ExcludeMissing + fun _workspace(): JsonField = workspace + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + @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 + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateLastEvaluated: JsonField? = null + private var dateLastSampleReceived: JsonField? = null + private var dateOfNextEvaluation: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonField? = null + private var failingGoalCount: JsonField? = null + private var links: JsonField? = null + private var name: JsonField? = null + private var passingGoalCount: JsonField? = null + private var bodyProjectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var totalGoalCount: JsonField? = null + private var project: JsonField = JsonMissing.of() + private var workspace: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + id = body.id + dateCreated = body.dateCreated + dateLastEvaluated = body.dateLastEvaluated + dateLastSampleReceived = body.dateLastSampleReceived + dateOfNextEvaluation = body.dateOfNextEvaluation + dateUpdated = body.dateUpdated + description = body.description + failingGoalCount = body.failingGoalCount + links = body.links + name = body.name + passingGoalCount = body.passingGoalCount + bodyProjectId = body.bodyProjectId + status = body.status + statusMessage = body.statusMessage + totalGoalCount = body.totalGoalCount + project = body.project + workspace = body.workspace + workspaceId = body.workspaceId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The inference pipeline id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime?) = + dateLastEvaluated(JsonField.ofNullable(dateLastEvaluated)) + + /** + * Alias for calling [Builder.dateLastEvaluated] with `dateLastEvaluated.orElse(null)`. + */ + fun dateLastEvaluated(dateLastEvaluated: Optional) = + dateLastEvaluated(dateLastEvaluated.getOrNull()) + + /** + * Sets [Builder.dateLastEvaluated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastEvaluated] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + this.dateLastEvaluated = dateLastEvaluated + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime?) = + dateLastSampleReceived(JsonField.ofNullable(dateLastSampleReceived)) + + /** + * Alias for calling [Builder.dateLastSampleReceived] with + * `dateLastSampleReceived.orElse(null)`. + */ + fun dateLastSampleReceived(dateLastSampleReceived: Optional) = + dateLastSampleReceived(dateLastSampleReceived.getOrNull()) + + /** + * Sets [Builder.dateLastSampleReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastSampleReceived] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + this.dateLastSampleReceived = dateLastSampleReceived + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime?) = + dateOfNextEvaluation(JsonField.ofNullable(dateOfNextEvaluation)) + + /** + * Alias for calling [Builder.dateOfNextEvaluation] with + * `dateOfNextEvaluation.orElse(null)`. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: Optional) = + dateOfNextEvaluation(dateOfNextEvaluation.getOrNull()) + + /** + * Sets [Builder.dateOfNextEvaluation] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfNextEvaluation] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + this.dateOfNextEvaluation = dateOfNextEvaluation + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The inference pipeline name. */ + 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 } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun bodyProjectId(bodyProjectId: String) = bodyProjectId(JsonField.of(bodyProjectId)) + + /** + * Sets [Builder.bodyProjectId] to an arbitrary JSON value. + * + * You should usually call [Builder.bodyProjectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bodyProjectId(bodyProjectId: JsonField) = apply { + this.bodyProjectId = bodyProjectId + } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + fun project(project: Project?) = project(JsonField.ofNullable(project)) + + /** Alias for calling [Builder.project] with `project.orElse(null)`. */ + fun project(project: Optional) = project(project.getOrNull()) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [Project] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun workspace(workspace: Workspace?) = workspace(JsonField.ofNullable(workspace)) + + /** Alias for calling [Builder.workspace] with `workspace.orElse(null)`. */ + fun workspace(workspace: Optional) = workspace(workspace.getOrNull()) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + /** The workspace id. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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 + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .bodyProjectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateLastEvaluated", dateLastEvaluated), + checkRequired("dateLastSampleReceived", dateLastSampleReceived), + checkRequired("dateOfNextEvaluation", dateOfNextEvaluation), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("links", links), + checkRequired("name", name), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("bodyProjectId", bodyProjectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("totalGoalCount", totalGoalCount), + project, + workspace, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateLastEvaluated() + dateLastSampleReceived() + dateOfNextEvaluation() + dateUpdated() + description() + failingGoalCount() + links().validate() + name() + passingGoalCount() + bodyProjectId() + status().validate() + statusMessage() + totalGoalCount() + project().ifPresent { it.validate() } + workspace().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (bodyProjectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && id == other.id && dateCreated == other.dateCreated && dateLastEvaluated == other.dateLastEvaluated && dateLastSampleReceived == other.dateLastSampleReceived && dateOfNextEvaluation == other.dateOfNextEvaluation && dateUpdated == other.dateUpdated && description == other.description && failingGoalCount == other.failingGoalCount && links == other.links && name == other.name && passingGoalCount == other.passingGoalCount && bodyProjectId == other.bodyProjectId && status == other.status && statusMessage == other.statusMessage && totalGoalCount == other.totalGoalCount && project == other.project && workspace == other.workspace && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateLastEvaluated, dateLastSampleReceived, dateOfNextEvaluation, dateUpdated, description, failingGoalCount, links, name, passingGoalCount, bodyProjectId, status, statusMessage, totalGoalCount, project, workspace, workspaceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{id=$id, dateCreated=$dateCreated, dateLastEvaluated=$dateLastEvaluated, dateLastSampleReceived=$dateLastSampleReceived, dateOfNextEvaluation=$dateOfNextEvaluation, dateUpdated=$dateUpdated, description=$description, failingGoalCount=$failingGoalCount, links=$links, name=$name, passingGoalCount=$passingGoalCount, bodyProjectId=$bodyProjectId, status=$status, statusMessage=$statusMessage, totalGoalCount=$totalGoalCount, project=$project, workspace=$workspace, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + } + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The status of test evaluation for the inference pipeline. */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Project + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 [Project]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Project]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(project: Project) = apply { + id = project.id + creatorId = project.creatorId + dateCreated = project.dateCreated + dateUpdated = project.dateUpdated + developmentGoalCount = project.developmentGoalCount + goalCount = project.goalCount + inferencePipelineCount = project.inferencePipelineCount + links = project.links + monitoringGoalCount = project.monitoringGoalCount + name = project.name + source = project.source + taskType = project.taskType + versionCount = project.versionCount + workspaceId = project.workspaceId + description = project.description + gitRepo = project.gitRepo + additionalProperties = project.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Project]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Project = + Project( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Project = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** + * An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** + * An enum member indicating that [TaskType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") + @ExcludeMissing + rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Project && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Project{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + class Workspace + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException 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 inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException 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 memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodEndDate(): Optional = periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodStartDate(): Optional = + periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException 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 projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = + wildcardDomains.getOptional("wildcardDomains") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCount") + @ExcludeMissing + fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * 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 [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") + @ExcludeMissing + fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @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 [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + creatorId = workspace.creatorId + dateCreated = workspace.dateCreated + dateUpdated = workspace.dateUpdated + inviteCount = workspace.inviteCount + memberCount = workspace.memberCount + name = workspace.name + periodEndDate = workspace.periodEndDate + periodStartDate = workspace.periodStartDate + projectCount = workspace.projectCount + slug = workspace.slug + status = workspace.status + inviteCode = workspace.inviteCode + monthlyUsage = workspace.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspace.samlOnlyAccess + wildcardDomains = workspace.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + 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 } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** The workspace name. */ + 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 } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectCount(projectCount: JsonField) = apply { + this.projectCount = projectCount + } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = + samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** + * An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionCount(): Optional = predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @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 [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = + executionTimeMs(executionTimeMs as Long?) + + /** + * Alias for calling [Builder.executionTimeMs] with `executionTimeMs.orElse(null)`. + */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun monthYear(monthYear: JsonField) = apply { + this.monthYear = monthYear + } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MonthlyUsage && executionTimeMs == other.executionTimeMs && monthYear == other.monthYear && predictionCount == other.predictionCount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Workspace && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && inviteCount == other.inviteCount && memberCount == other.memberCount && name == other.name && periodEndDate == other.periodEndDate && periodStartDate == other.periodStartDate && projectCount == other.projectCount && slug == other.slug && status == other.status && inviteCode == other.inviteCode && monthlyUsage == other.monthlyUsage && samlOnlyAccess == other.samlOnlyAccess && wildcardDomains == other.wildcardDomains && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, inviteCount, memberCount, name, periodEndDate, periodStartDate, projectCount, slug, status, inviteCode, monthlyUsage, samlOnlyAccess, wildcardDomains, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineCreateParams && pathProjectId == other.pathProjectId && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(pathProjectId, body, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "InferencePipelineCreateParams{pathProjectId=$pathProjectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt new file mode 100644 index 00000000..c04c36d6 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt @@ -0,0 +1,4227 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InferencePipelineCreateResponse +private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateLastEvaluated: JsonField, + private val dateLastSampleReceived: JsonField, + private val dateOfNextEvaluation: JsonField, + private val dateUpdated: JsonField, + private val description: JsonField, + private val failingGoalCount: JsonField, + private val links: JsonField, + private val name: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val totalGoalCount: JsonField, + private val project: JsonField, + private val workspace: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + dateLastEvaluated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + dateLastSampleReceived: JsonField = JsonMissing.of(), + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + dateOfNextEvaluation: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("project") @ExcludeMissing project: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateLastEvaluated, + dateLastSampleReceived, + dateOfNextEvaluation, + dateUpdated, + description, + failingGoalCount, + links, + name, + passingGoalCount, + projectId, + status, + statusMessage, + totalGoalCount, + project, + workspace, + workspaceId, + mutableMapOf(), + ) + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastEvaluated(): Optional = + dateLastEvaluated.getOptional("dateLastEvaluated") + + /** + * The last data sample received date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastSampleReceived(): Optional = + dateLastSampleReceived.getOptional("dateLastSampleReceived") + + /** + * The next test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateOfNextEvaluation(): Optional = + dateOfNextEvaluation.getOptional("dateOfNextEvaluation") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The number of tests failing. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of tests passing. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The status of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The total number of tests. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspace(): Optional = workspace.getOptional("workspace") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateLastEvaluated]. + * + * Unlike [dateLastEvaluated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + fun _dateLastEvaluated(): JsonField = dateLastEvaluated + + /** + * Returns the raw JSON value of [dateLastSampleReceived]. + * + * Unlike [dateLastSampleReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun _dateLastSampleReceived(): JsonField = dateLastSampleReceived + + /** + * Returns the raw JSON value of [dateOfNextEvaluation]. + * + * Unlike [dateOfNextEvaluation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun _dateOfNextEvaluation(): JsonField = dateOfNextEvaluation + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * 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 [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") @ExcludeMissing fun _workspace(): JsonField = workspace + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") @ExcludeMissing fun _workspaceId(): JsonField = workspaceId + + @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 + * [InferencePipelineCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateLastEvaluated: JsonField? = null + private var dateLastSampleReceived: JsonField? = null + private var dateOfNextEvaluation: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonField? = null + private var failingGoalCount: JsonField? = null + private var links: JsonField? = null + private var name: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var totalGoalCount: JsonField? = null + private var project: JsonField = JsonMissing.of() + private var workspace: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineCreateResponse: InferencePipelineCreateResponse) = + apply { + id = inferencePipelineCreateResponse.id + dateCreated = inferencePipelineCreateResponse.dateCreated + dateLastEvaluated = inferencePipelineCreateResponse.dateLastEvaluated + dateLastSampleReceived = inferencePipelineCreateResponse.dateLastSampleReceived + dateOfNextEvaluation = inferencePipelineCreateResponse.dateOfNextEvaluation + dateUpdated = inferencePipelineCreateResponse.dateUpdated + description = inferencePipelineCreateResponse.description + failingGoalCount = inferencePipelineCreateResponse.failingGoalCount + links = inferencePipelineCreateResponse.links + name = inferencePipelineCreateResponse.name + passingGoalCount = inferencePipelineCreateResponse.passingGoalCount + projectId = inferencePipelineCreateResponse.projectId + status = inferencePipelineCreateResponse.status + statusMessage = inferencePipelineCreateResponse.statusMessage + totalGoalCount = inferencePipelineCreateResponse.totalGoalCount + project = inferencePipelineCreateResponse.project + workspace = inferencePipelineCreateResponse.workspace + workspaceId = inferencePipelineCreateResponse.workspaceId + additionalProperties = + inferencePipelineCreateResponse.additionalProperties.toMutableMap() + } + + /** The inference pipeline id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime?) = + dateLastEvaluated(JsonField.ofNullable(dateLastEvaluated)) + + /** Alias for calling [Builder.dateLastEvaluated] with `dateLastEvaluated.orElse(null)`. */ + fun dateLastEvaluated(dateLastEvaluated: Optional) = + dateLastEvaluated(dateLastEvaluated.getOrNull()) + + /** + * Sets [Builder.dateLastEvaluated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastEvaluated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + this.dateLastEvaluated = dateLastEvaluated + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime?) = + dateLastSampleReceived(JsonField.ofNullable(dateLastSampleReceived)) + + /** + * Alias for calling [Builder.dateLastSampleReceived] with + * `dateLastSampleReceived.orElse(null)`. + */ + fun dateLastSampleReceived(dateLastSampleReceived: Optional) = + dateLastSampleReceived(dateLastSampleReceived.getOrNull()) + + /** + * Sets [Builder.dateLastSampleReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastSampleReceived] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + this.dateLastSampleReceived = dateLastSampleReceived + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime?) = + dateOfNextEvaluation(JsonField.ofNullable(dateOfNextEvaluation)) + + /** + * Alias for calling [Builder.dateOfNextEvaluation] with + * `dateOfNextEvaluation.orElse(null)`. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: Optional) = + dateOfNextEvaluation(dateOfNextEvaluation.getOrNull()) + + /** + * Sets [Builder.dateOfNextEvaluation] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfNextEvaluation] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + this.dateOfNextEvaluation = dateOfNextEvaluation + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The inference pipeline name. */ + 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 } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + fun project(project: Project?) = project(JsonField.ofNullable(project)) + + /** Alias for calling [Builder.project] with `project.orElse(null)`. */ + fun project(project: Optional) = project(project.getOrNull()) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [Project] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun workspace(workspace: Workspace?) = workspace(JsonField.ofNullable(workspace)) + + /** Alias for calling [Builder.workspace] with `workspace.orElse(null)`. */ + fun workspace(workspace: Optional) = workspace(workspace.getOrNull()) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + /** The workspace id. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun workspaceId(workspaceId: JsonField) = apply { this.workspaceId = workspaceId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InferencePipelineCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InferencePipelineCreateResponse = + InferencePipelineCreateResponse( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateLastEvaluated", dateLastEvaluated), + checkRequired("dateLastSampleReceived", dateLastSampleReceived), + checkRequired("dateOfNextEvaluation", dateOfNextEvaluation), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("links", links), + checkRequired("name", name), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("totalGoalCount", totalGoalCount), + project, + workspace, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InferencePipelineCreateResponse = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateLastEvaluated() + dateLastSampleReceived() + dateOfNextEvaluation() + dateUpdated() + description() + failingGoalCount() + links().validate() + name() + passingGoalCount() + projectId() + status().validate() + statusMessage() + totalGoalCount() + project().ifPresent { it.validate() } + workspace().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The status of test evaluation for the inference pipeline. */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Project + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") @ExcludeMissing gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taskType") @ExcludeMissing fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 [Project]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Project]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(project: Project) = apply { + id = project.id + creatorId = project.creatorId + dateCreated = project.dateCreated + dateUpdated = project.dateUpdated + developmentGoalCount = project.developmentGoalCount + goalCount = project.goalCount + inferencePipelineCount = project.inferencePipelineCount + links = project.links + monitoringGoalCount = project.monitoringGoalCount + name = project.name + source = project.source + taskType = project.taskType + versionCount = project.versionCount + workspaceId = project.workspaceId + description = project.description + gitRepo = project.gitRepo + additionalProperties = project.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Project]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Project = + Project( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Project = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** + * An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** + * An enum member indicating that [TaskType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") @ExcludeMissing gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") + @ExcludeMissing + rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("private") @ExcludeMissing fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Project && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Project{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + class Workspace + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException 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 inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException 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 memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodEndDate(): Optional = periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun periodStartDate(): Optional = + periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException 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 projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = + wildcardDomains.getOptional("wildcardDomains") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCount") + @ExcludeMissing + fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * 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 [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") + @ExcludeMissing + fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @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 [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + creatorId = workspace.creatorId + dateCreated = workspace.dateCreated + dateUpdated = workspace.dateUpdated + inviteCount = workspace.inviteCount + memberCount = workspace.memberCount + name = workspace.name + periodEndDate = workspace.periodEndDate + periodStartDate = workspace.periodStartDate + projectCount = workspace.projectCount + slug = workspace.slug + status = workspace.status + inviteCode = workspace.inviteCode + monthlyUsage = workspace.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspace.samlOnlyAccess + wildcardDomains = workspace.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + 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 } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** The workspace name. */ + 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 } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectCount(projectCount: JsonField) = apply { + this.projectCount = projectCount + } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = + samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** + * An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun predictionCount(): Optional = predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @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 [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = + executionTimeMs(executionTimeMs as Long?) + + /** + * Alias for calling [Builder.executionTimeMs] with `executionTimeMs.orElse(null)`. + */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun monthYear(monthYear: JsonField) = apply { + this.monthYear = monthYear + } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MonthlyUsage && executionTimeMs == other.executionTimeMs && monthYear == other.monthYear && predictionCount == other.predictionCount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Workspace && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && inviteCount == other.inviteCount && memberCount == other.memberCount && name == other.name && periodEndDate == other.periodEndDate && periodStartDate == other.periodStartDate && projectCount == other.projectCount && slug == other.slug && status == other.status && inviteCode == other.inviteCode && monthlyUsage == other.monthlyUsage && samlOnlyAccess == other.samlOnlyAccess && wildcardDomains == other.wildcardDomains && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, inviteCount, memberCount, name, periodEndDate, periodStartDate, projectCount, slug, status, inviteCode, monthlyUsage, samlOnlyAccess, wildcardDomains, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineCreateResponse && id == other.id && dateCreated == other.dateCreated && dateLastEvaluated == other.dateLastEvaluated && dateLastSampleReceived == other.dateLastSampleReceived && dateOfNextEvaluation == other.dateOfNextEvaluation && dateUpdated == other.dateUpdated && description == other.description && failingGoalCount == other.failingGoalCount && links == other.links && name == other.name && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && totalGoalCount == other.totalGoalCount && project == other.project && workspace == other.workspace && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateLastEvaluated, dateLastSampleReceived, dateOfNextEvaluation, dateUpdated, description, failingGoalCount, links, name, passingGoalCount, projectId, status, statusMessage, totalGoalCount, project, workspace, workspaceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InferencePipelineCreateResponse{id=$id, dateCreated=$dateCreated, dateLastEvaluated=$dateLastEvaluated, dateLastSampleReceived=$dateLastSampleReceived, dateOfNextEvaluation=$dateOfNextEvaluation, dateUpdated=$dateUpdated, description=$description, failingGoalCount=$failingGoalCount, links=$links, name=$name, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, totalGoalCount=$totalGoalCount, project=$project, workspace=$workspace, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListParams.kt new file mode 100644 index 00000000..298de86b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListParams.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List the inference pipelines in a project. */ +class InferencePipelineListParams +private constructor( + private val projectId: String, + private val name: String?, + private val page: Long?, + private val perPage: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun projectId(): String = projectId + + /** Filter list of items by name. */ + fun name(): Optional = Optional.ofNullable(name) + + /** The page to return in a paginated query. */ + fun page(): Optional = Optional.ofNullable(page) + + /** Maximum number of items to return per page. */ + fun perPage(): Optional = Optional.ofNullable(perPage) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InferencePipelineListParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineListParams]. */ + class Builder internal constructor() { + + private var projectId: String? = null + private var name: String? = null + private var page: Long? = null + private var perPage: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inferencePipelineListParams: InferencePipelineListParams) = apply { + projectId = inferencePipelineListParams.projectId + name = inferencePipelineListParams.name + page = inferencePipelineListParams.page + perPage = inferencePipelineListParams.perPage + additionalHeaders = inferencePipelineListParams.additionalHeaders.toBuilder() + additionalQueryParams = inferencePipelineListParams.additionalQueryParams.toBuilder() + } + + fun projectId(projectId: String) = apply { this.projectId = projectId } + + /** Filter list of items by name. */ + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** The page to return in a paginated query. */ + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.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 [InferencePipelineListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InferencePipelineListParams = + InferencePipelineListParams( + checkRequired("projectId", projectId), + name, + page, + perPage, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> projectId + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + name?.let { put("name", it) } + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineListParams && projectId == other.projectId && name == other.name && page == other.page && perPage == other.perPage && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(projectId, name, page, perPage, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "InferencePipelineListParams{projectId=$projectId, name=$name, page=$page, perPage=$perPage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt new file mode 100644 index 00000000..38b3bf4c --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt @@ -0,0 +1,4516 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +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.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InferencePipelineListResponse +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 + * [InferencePipelineListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineListResponse: InferencePipelineListResponse) = apply { + items = inferencePipelineListResponse.items.map { it.toMutableList() } + additionalProperties = inferencePipelineListResponse.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 [InferencePipelineListResponse]. + * + * 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(): InferencePipelineListResponse = + InferencePipelineListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InferencePipelineListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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) + + class Item + private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateLastEvaluated: JsonField, + private val dateLastSampleReceived: JsonField, + private val dateOfNextEvaluation: JsonField, + private val dateUpdated: JsonField, + private val description: JsonField, + private val failingGoalCount: JsonField, + private val links: JsonField, + private val name: JsonField, + private val passingGoalCount: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val totalGoalCount: JsonField, + private val project: JsonField, + private val workspace: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + dateLastEvaluated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + dateLastSampleReceived: JsonField = JsonMissing.of(), + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + dateOfNextEvaluation: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("failingGoalCount") + @ExcludeMissing + failingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("passingGoalCount") + @ExcludeMissing + passingGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("statusMessage") + @ExcludeMissing + statusMessage: JsonField = JsonMissing.of(), + @JsonProperty("totalGoalCount") + @ExcludeMissing + totalGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("project") @ExcludeMissing project: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + dateCreated, + dateLastEvaluated, + dateLastSampleReceived, + dateOfNextEvaluation, + dateUpdated, + description, + failingGoalCount, + links, + name, + passingGoalCount, + projectId, + status, + statusMessage, + totalGoalCount, + project, + workspace, + workspaceId, + mutableMapOf(), + ) + + /** + * The inference pipeline id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The last test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateLastEvaluated(): Optional = + dateLastEvaluated.getOptional("dateLastEvaluated") + + /** + * The last data sample received date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateLastSampleReceived(): Optional = + dateLastSampleReceived.getOptional("dateLastSampleReceived") + + /** + * The next test evaluation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun dateOfNextEvaluation(): Optional = + dateOfNextEvaluation.getOptional("dateOfNextEvaluation") + + /** + * The last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The inference pipeline description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The number of tests failing. + * + * @throws OpenlayerInvalidDataException 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 failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The inference pipeline name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The number of tests passing. + * + * @throws OpenlayerInvalidDataException 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 passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * The status of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The status message of test evaluation for the inference pipeline. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusMessage(): Optional = statusMessage.getOptional("statusMessage") + + /** + * The total number of tests. + * + * @throws OpenlayerInvalidDataException 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 totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun project(): Optional = project.getOptional("project") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspace(): Optional = workspace.getOptional("workspace") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * 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 [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateLastEvaluated]. + * + * Unlike [dateLastEvaluated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + fun _dateLastEvaluated(): JsonField = dateLastEvaluated + + /** + * Returns the raw JSON value of [dateLastSampleReceived]. + * + * Unlike [dateLastSampleReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun _dateLastSampleReceived(): JsonField = dateLastSampleReceived + + /** + * Returns the raw JSON value of [dateOfNextEvaluation]. + * + * Unlike [dateOfNextEvaluation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun _dateOfNextEvaluation(): JsonField = dateOfNextEvaluation + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [failingGoalCount]. + * + * Unlike [failingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun _failingGoalCount(): JsonField = failingGoalCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * 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 [passingGoalCount]. + * + * Unlike [passingGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun _passingGoalCount(): JsonField = passingGoalCount + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusMessage]. + * + * Unlike [statusMessage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun _statusMessage(): JsonField = statusMessage + + /** + * Returns the raw JSON value of [totalGoalCount]. + * + * Unlike [totalGoalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun _totalGoalCount(): JsonField = totalGoalCount + + /** + * Returns the raw JSON value of [project]. + * + * Unlike [project], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project") @ExcludeMissing fun _project(): JsonField = project + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") + @ExcludeMissing + fun _workspace(): JsonField = workspace + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + @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() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateLastEvaluated: JsonField? = null + private var dateLastSampleReceived: JsonField? = null + private var dateOfNextEvaluation: JsonField? = null + private var dateUpdated: JsonField? = null + private var description: JsonField? = null + private var failingGoalCount: JsonField? = null + private var links: JsonField? = null + private var name: JsonField? = null + private var passingGoalCount: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var statusMessage: JsonField? = null + private var totalGoalCount: JsonField? = null + private var project: JsonField = JsonMissing.of() + private var workspace: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + dateCreated = item.dateCreated + dateLastEvaluated = item.dateLastEvaluated + dateLastSampleReceived = item.dateLastSampleReceived + dateOfNextEvaluation = item.dateOfNextEvaluation + dateUpdated = item.dateUpdated + description = item.description + failingGoalCount = item.failingGoalCount + links = item.links + name = item.name + passingGoalCount = item.passingGoalCount + projectId = item.projectId + status = item.status + statusMessage = item.statusMessage + totalGoalCount = item.totalGoalCount + project = item.project + workspace = item.workspace + workspaceId = item.workspaceId + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The inference pipeline id. */ + 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 } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime?) = + dateLastEvaluated(JsonField.ofNullable(dateLastEvaluated)) + + /** + * Alias for calling [Builder.dateLastEvaluated] with `dateLastEvaluated.orElse(null)`. + */ + fun dateLastEvaluated(dateLastEvaluated: Optional) = + dateLastEvaluated(dateLastEvaluated.getOrNull()) + + /** + * Sets [Builder.dateLastEvaluated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastEvaluated] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + this.dateLastEvaluated = dateLastEvaluated + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime?) = + dateLastSampleReceived(JsonField.ofNullable(dateLastSampleReceived)) + + /** + * Alias for calling [Builder.dateLastSampleReceived] with + * `dateLastSampleReceived.orElse(null)`. + */ + fun dateLastSampleReceived(dateLastSampleReceived: Optional) = + dateLastSampleReceived(dateLastSampleReceived.getOrNull()) + + /** + * Sets [Builder.dateLastSampleReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastSampleReceived] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + this.dateLastSampleReceived = dateLastSampleReceived + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime?) = + dateOfNextEvaluation(JsonField.ofNullable(dateOfNextEvaluation)) + + /** + * Alias for calling [Builder.dateOfNextEvaluation] with + * `dateOfNextEvaluation.orElse(null)`. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: Optional) = + dateOfNextEvaluation(dateOfNextEvaluation.getOrNull()) + + /** + * Sets [Builder.dateOfNextEvaluation] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfNextEvaluation] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + this.dateOfNextEvaluation = dateOfNextEvaluation + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The inference pipeline description. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** + * Sets [Builder.failingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.failingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The inference pipeline name. */ + 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 } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** + * Sets [Builder.passingGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.passingGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String?) = + statusMessage(JsonField.ofNullable(statusMessage)) + + /** Alias for calling [Builder.statusMessage] with `statusMessage.orElse(null)`. */ + fun statusMessage(statusMessage: Optional) = + statusMessage(statusMessage.getOrNull()) + + /** + * Sets [Builder.statusMessage] to an arbitrary JSON value. + * + * You should usually call [Builder.statusMessage] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** + * Sets [Builder.totalGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalGoalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + fun project(project: Project?) = project(JsonField.ofNullable(project)) + + /** Alias for calling [Builder.project] with `project.orElse(null)`. */ + fun project(project: Optional) = project(project.getOrNull()) + + /** + * Sets [Builder.project] to an arbitrary JSON value. + * + * You should usually call [Builder.project] with a well-typed [Project] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun project(project: JsonField) = apply { this.project = project } + + fun workspace(workspace: Workspace?) = workspace(JsonField.ofNullable(workspace)) + + /** Alias for calling [Builder.workspace] with `workspace.orElse(null)`. */ + fun workspace(workspace: Optional) = workspace(workspace.getOrNull()) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + /** The workspace id. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.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() + * .dateCreated() + * .dateLastEvaluated() + * .dateLastSampleReceived() + * .dateOfNextEvaluation() + * .dateUpdated() + * .description() + * .failingGoalCount() + * .links() + * .name() + * .passingGoalCount() + * .projectId() + * .status() + * .statusMessage() + * .totalGoalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateLastEvaluated", dateLastEvaluated), + checkRequired("dateLastSampleReceived", dateLastSampleReceived), + checkRequired("dateOfNextEvaluation", dateOfNextEvaluation), + checkRequired("dateUpdated", dateUpdated), + checkRequired("description", description), + checkRequired("failingGoalCount", failingGoalCount), + checkRequired("links", links), + checkRequired("name", name), + checkRequired("passingGoalCount", passingGoalCount), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("statusMessage", statusMessage), + checkRequired("totalGoalCount", totalGoalCount), + project, + workspace, + workspaceId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateLastEvaluated() + dateLastSampleReceived() + dateOfNextEvaluation() + dateUpdated() + description() + failingGoalCount() + links().validate() + name() + passingGoalCount() + projectId() + status().validate() + statusMessage() + totalGoalCount() + project().ifPresent { it.validate() } + workspace().ifPresent { it.validate() } + workspaceId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The status of test evaluation for the inference pipeline. */ + class Status @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 QUEUED = of("queued") + + @JvmField val RUNNING = of("running") + + @JvmField val PAUSED = of("paused") + + @JvmField val FAILED = of("failed") + + @JvmField val COMPLETED = of("completed") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + /** + * An enum member indicating that [Status] 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) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + 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 OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Project + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val developmentGoalCount: JsonField, + private val goalCount: JsonField, + private val inferencePipelineCount: JsonField, + private val links: JsonField, + private val monitoringGoalCount: JsonField, + private val name: JsonField, + private val source: JsonField, + private val taskType: JsonField, + private val versionCount: JsonField, + private val workspaceId: JsonField, + private val description: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("developmentGoalCount") + @ExcludeMissing + developmentGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("goalCount") + @ExcludeMissing + goalCount: JsonField = JsonMissing.of(), + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + inferencePipelineCount: JsonField = JsonMissing.of(), + @JsonProperty("links") @ExcludeMissing links: JsonField = JsonMissing.of(), + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + monitoringGoalCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("taskType") + @ExcludeMissing + taskType: JsonField = JsonMissing.of(), + @JsonProperty("versionCount") + @ExcludeMissing + versionCount: JsonField = JsonMissing.of(), + @JsonProperty("workspaceId") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("gitRepo") + @ExcludeMissing + gitRepo: JsonField = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + developmentGoalCount, + goalCount, + inferencePipelineCount, + links, + monitoringGoalCount, + name, + source, + taskType, + versionCount, + workspaceId, + description, + gitRepo, + mutableMapOf(), + ) + + /** + * The project id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The project creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The project creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The project last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of tests in the development mode of the project. + * + * @throws OpenlayerInvalidDataException 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 developmentGoalCount(): Long = + developmentGoalCount.getRequired("developmentGoalCount") + + /** + * The total number of tests in the project. + * + * @throws OpenlayerInvalidDataException 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 goalCount(): Long = goalCount.getRequired("goalCount") + + /** + * The number of inference pipelines in the project. + * + * @throws OpenlayerInvalidDataException 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 inferencePipelineCount(): Long = + inferencePipelineCount.getRequired("inferencePipelineCount") + + /** + * Links to the project. + * + * @throws OpenlayerInvalidDataException 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 links(): Links = links.getRequired("links") + + /** + * The number of tests in the monitoring mode of the project. + * + * @throws OpenlayerInvalidDataException 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 monitoringGoalCount(): Long = monitoringGoalCount.getRequired("monitoringGoalCount") + + /** + * The project name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The source of the project. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The task type of the project. + * + * @throws OpenlayerInvalidDataException 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 taskType(): TaskType = taskType.getRequired("taskType") + + /** + * The number of versions (commits) in the project. + * + * @throws OpenlayerInvalidDataException 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 versionCount(): Long = versionCount.getRequired("versionCount") + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspaceId") + + /** + * The project description. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gitRepo(): Optional = gitRepo.getOptional("gitRepo") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("creatorId") + @ExcludeMissing + fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [developmentGoalCount]. + * + * Unlike [developmentGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("developmentGoalCount") + @ExcludeMissing + fun _developmentGoalCount(): JsonField = developmentGoalCount + + /** + * Returns the raw JSON value of [goalCount]. + * + * Unlike [goalCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("goalCount") @ExcludeMissing fun _goalCount(): JsonField = goalCount + + /** + * Returns the raw JSON value of [inferencePipelineCount]. + * + * Unlike [inferencePipelineCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("inferencePipelineCount") + @ExcludeMissing + fun _inferencePipelineCount(): JsonField = inferencePipelineCount + + /** + * Returns the raw JSON value of [links]. + * + * Unlike [links], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("links") @ExcludeMissing fun _links(): JsonField = links + + /** + * Returns the raw JSON value of [monitoringGoalCount]. + * + * Unlike [monitoringGoalCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("monitoringGoalCount") + @ExcludeMissing + fun _monitoringGoalCount(): JsonField = monitoringGoalCount + + /** + * 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 [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [taskType]. + * + * Unlike [taskType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("taskType") + @ExcludeMissing + fun _taskType(): JsonField = taskType + + /** + * Returns the raw JSON value of [versionCount]. + * + * Unlike [versionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("versionCount") + @ExcludeMissing + fun _versionCount(): JsonField = versionCount + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("workspaceId") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [gitRepo]. + * + * Unlike [gitRepo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gitRepo") @ExcludeMissing fun _gitRepo(): JsonField = gitRepo + + @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 [Project]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Project]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var developmentGoalCount: JsonField? = null + private var goalCount: JsonField? = null + private var inferencePipelineCount: JsonField? = null + private var links: JsonField? = null + private var monitoringGoalCount: JsonField? = null + private var name: JsonField? = null + private var source: JsonField? = null + private var taskType: JsonField? = null + private var versionCount: JsonField? = null + private var workspaceId: JsonField? = null + private var description: JsonField = JsonMissing.of() + private var gitRepo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(project: Project) = apply { + id = project.id + creatorId = project.creatorId + dateCreated = project.dateCreated + dateUpdated = project.dateUpdated + developmentGoalCount = project.developmentGoalCount + goalCount = project.goalCount + inferencePipelineCount = project.inferencePipelineCount + links = project.links + monitoringGoalCount = project.monitoringGoalCount + name = project.name + source = project.source + taskType = project.taskType + versionCount = project.versionCount + workspaceId = project.workspaceId + description = project.description + gitRepo = project.gitRepo + additionalProperties = project.additionalProperties.toMutableMap() + } + + /** The project id. */ + 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 } + + /** The project creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The project creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The project last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of tests in the development mode of the project. */ + fun developmentGoalCount(developmentGoalCount: Long) = + developmentGoalCount(JsonField.of(developmentGoalCount)) + + /** + * Sets [Builder.developmentGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.developmentGoalCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun developmentGoalCount(developmentGoalCount: JsonField) = apply { + this.developmentGoalCount = developmentGoalCount + } + + /** The total number of tests in the project. */ + fun goalCount(goalCount: Long) = goalCount(JsonField.of(goalCount)) + + /** + * Sets [Builder.goalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.goalCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun goalCount(goalCount: JsonField) = apply { this.goalCount = goalCount } + + /** The number of inference pipelines in the project. */ + fun inferencePipelineCount(inferencePipelineCount: Long) = + inferencePipelineCount(JsonField.of(inferencePipelineCount)) + + /** + * Sets [Builder.inferencePipelineCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inferencePipelineCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun inferencePipelineCount(inferencePipelineCount: JsonField) = apply { + this.inferencePipelineCount = inferencePipelineCount + } + + /** Links to the project. */ + fun links(links: Links) = links(JsonField.of(links)) + + /** + * Sets [Builder.links] to an arbitrary JSON value. + * + * You should usually call [Builder.links] with a well-typed [Links] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun links(links: JsonField) = apply { this.links = links } + + /** The number of tests in the monitoring mode of the project. */ + fun monitoringGoalCount(monitoringGoalCount: Long) = + monitoringGoalCount(JsonField.of(monitoringGoalCount)) + + /** + * Sets [Builder.monitoringGoalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.monitoringGoalCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun monitoringGoalCount(monitoringGoalCount: JsonField) = apply { + this.monitoringGoalCount = monitoringGoalCount + } + + /** The project name. */ + 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 } + + /** The source of the project. */ + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The task type of the project. */ + fun taskType(taskType: TaskType) = taskType(JsonField.of(taskType)) + + /** + * Sets [Builder.taskType] to an arbitrary JSON value. + * + * You should usually call [Builder.taskType] with a well-typed [TaskType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taskType(taskType: JsonField) = apply { this.taskType = taskType } + + /** The number of versions (commits) in the project. */ + fun versionCount(versionCount: Long) = versionCount(JsonField.of(versionCount)) + + /** + * Sets [Builder.versionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.versionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun versionCount(versionCount: JsonField) = apply { + this.versionCount = versionCount + } + + /** The workspace id. */ + fun workspaceId(workspaceId: String?) = + workspaceId(JsonField.ofNullable(workspaceId)) + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = + workspaceId(workspaceId.getOrNull()) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + + /** The project description. */ + fun description(description: String?) = + description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = + description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + fun gitRepo(gitRepo: GitRepo?) = gitRepo(JsonField.ofNullable(gitRepo)) + + /** Alias for calling [Builder.gitRepo] with `gitRepo.orElse(null)`. */ + fun gitRepo(gitRepo: Optional) = gitRepo(gitRepo.getOrNull()) + + /** + * Sets [Builder.gitRepo] to an arbitrary JSON value. + * + * You should usually call [Builder.gitRepo] with a well-typed [GitRepo] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gitRepo(gitRepo: JsonField) = apply { this.gitRepo = gitRepo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Project]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .developmentGoalCount() + * .goalCount() + * .inferencePipelineCount() + * .links() + * .monitoringGoalCount() + * .name() + * .source() + * .taskType() + * .versionCount() + * .workspaceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Project = + Project( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("developmentGoalCount", developmentGoalCount), + checkRequired("goalCount", goalCount), + checkRequired("inferencePipelineCount", inferencePipelineCount), + checkRequired("links", links), + checkRequired("monitoringGoalCount", monitoringGoalCount), + checkRequired("name", name), + checkRequired("source", source), + checkRequired("taskType", taskType), + checkRequired("versionCount", versionCount), + checkRequired("workspaceId", workspaceId), + description, + gitRepo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Project = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + developmentGoalCount() + goalCount() + inferencePipelineCount() + links().validate() + monitoringGoalCount() + name() + source().ifPresent { it.validate() } + taskType().validate() + versionCount() + workspaceId() + description() + gitRepo().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + + /** Links to the project. */ + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("app") @ExcludeMissing app: JsonField = JsonMissing.of() + ) : this(app, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException 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 app(): String = app.getRequired("app") + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + @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 [Links]. + * + * The following fields are required: + * ```java + * .app() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Links]. */ + class Builder internal constructor() { + + private var app: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + app = links.app + additionalProperties = links.additionalProperties.toMutableMap() + } + + fun app(app: String) = app(JsonField.of(app)) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Links]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .app() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Links = + Links(checkRequired("app", app), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Links = apply { + if (validated) { + return@apply + } + + app() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (app.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && app == other.app && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(app, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Links{app=$app, additionalProperties=$additionalProperties}" + } + + /** The source of the project. */ + class Source @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 WEB = of("web") + + @JvmField val API = of("api") + + @JvmField val NULL = of("null") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + WEB, + API, + NULL, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + WEB, + API, + NULL, + /** + * An enum member indicating that [Source] 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) { + WEB -> Value.WEB + API -> Value.API + NULL -> Value.NULL + 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 OpenlayerInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + WEB -> Known.WEB + API -> Known.API + NULL -> Known.NULL + else -> throw OpenlayerInvalidDataException("Unknown Source: $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 OpenlayerInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Source && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The task type of the project. */ + class TaskType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LLM_BASE = of("llm-base") + + @JvmField val TABULAR_CLASSIFICATION = of("tabular-classification") + + @JvmField val TABULAR_REGRESSION = of("tabular-regression") + + @JvmField val TEXT_CLASSIFICATION = of("text-classification") + + @JvmStatic fun of(value: String) = TaskType(JsonField.of(value)) + } + + /** An enum containing [TaskType]'s known values. */ + enum class Known { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + } + + /** + * An enum containing [TaskType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaskType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LLM_BASE, + TABULAR_CLASSIFICATION, + TABULAR_REGRESSION, + TEXT_CLASSIFICATION, + /** + * An enum member indicating that [TaskType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LLM_BASE -> Value.LLM_BASE + TABULAR_CLASSIFICATION -> Value.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Value.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Value.TEXT_CLASSIFICATION + 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 OpenlayerInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LLM_BASE -> Known.LLM_BASE + TABULAR_CLASSIFICATION -> Known.TABULAR_CLASSIFICATION + TABULAR_REGRESSION -> Known.TABULAR_REGRESSION + TEXT_CLASSIFICATION -> Known.TEXT_CLASSIFICATION + else -> throw OpenlayerInvalidDataException("Unknown TaskType: $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 OpenlayerInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is TaskType && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class GitRepo + private constructor( + private val id: JsonField, + private val dateConnected: JsonField, + private val dateUpdated: JsonField, + private val gitAccountId: JsonField, + private val gitId: JsonField, + private val name: JsonField, + private val private_: JsonField, + private val projectId: JsonField, + private val slug: JsonField, + private val url: JsonField, + private val branch: JsonField, + private val rootDir: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateConnected") + @ExcludeMissing + dateConnected: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("gitAccountId") + @ExcludeMissing + gitAccountId: JsonField = JsonMissing.of(), + @JsonProperty("gitId") + @ExcludeMissing + gitId: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("private") + @ExcludeMissing + private_: JsonField = JsonMissing.of(), + @JsonProperty("projectId") + @ExcludeMissing + projectId: JsonField = JsonMissing.of(), + @JsonProperty("slug") + @ExcludeMissing + slug: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("branch") + @ExcludeMissing + branch: JsonField = JsonMissing.of(), + @JsonProperty("rootDir") + @ExcludeMissing + rootDir: JsonField = JsonMissing.of(), + ) : this( + id, + dateConnected, + dateUpdated, + gitAccountId, + gitId, + name, + private_, + projectId, + slug, + url, + branch, + rootDir, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 dateConnected(): OffsetDateTime = dateConnected.getRequired("dateConnected") + + /** + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * @throws OpenlayerInvalidDataException 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 gitAccountId(): String = gitAccountId.getRequired("gitAccountId") + + /** + * @throws OpenlayerInvalidDataException 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 gitId(): Long = gitId.getRequired("gitId") + + /** + * @throws OpenlayerInvalidDataException 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 OpenlayerInvalidDataException 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 private_(): Boolean = private_.getRequired("private") + + /** + * @throws OpenlayerInvalidDataException 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 projectId(): String = projectId.getRequired("projectId") + + /** + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun branch(): Optional = branch.getOptional("branch") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun rootDir(): Optional = rootDir.getOptional("rootDir") + + /** + * 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 [dateConnected]. + * + * Unlike [dateConnected], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateConnected") + @ExcludeMissing + fun _dateConnected(): JsonField = dateConnected + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [gitAccountId]. + * + * Unlike [gitAccountId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("gitAccountId") + @ExcludeMissing + fun _gitAccountId(): JsonField = gitAccountId + + /** + * Returns the raw JSON value of [gitId]. + * + * Unlike [gitId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gitId") @ExcludeMissing fun _gitId(): JsonField = gitId + + /** + * 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 [private_]. + * + * Unlike [private_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("private") + @ExcludeMissing + fun _private_(): JsonField = private_ + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectId") + @ExcludeMissing + fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [branch]. + * + * Unlike [branch], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("branch") @ExcludeMissing fun _branch(): JsonField = branch + + /** + * Returns the raw JSON value of [rootDir]. + * + * Unlike [rootDir], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rootDir") @ExcludeMissing fun _rootDir(): JsonField = rootDir + + @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 [GitRepo]. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GitRepo]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateConnected: JsonField? = null + private var dateUpdated: JsonField? = null + private var gitAccountId: JsonField? = null + private var gitId: JsonField? = null + private var name: JsonField? = null + private var private_: JsonField? = null + private var projectId: JsonField? = null + private var slug: JsonField? = null + private var url: JsonField? = null + private var branch: JsonField = JsonMissing.of() + private var rootDir: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(gitRepo: GitRepo) = apply { + id = gitRepo.id + dateConnected = gitRepo.dateConnected + dateUpdated = gitRepo.dateUpdated + gitAccountId = gitRepo.gitAccountId + gitId = gitRepo.gitId + name = gitRepo.name + private_ = gitRepo.private_ + projectId = gitRepo.projectId + slug = gitRepo.slug + url = gitRepo.url + branch = gitRepo.branch + rootDir = gitRepo.rootDir + additionalProperties = gitRepo.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 dateConnected(dateConnected: OffsetDateTime) = + dateConnected(JsonField.of(dateConnected)) + + /** + * Sets [Builder.dateConnected] to an arbitrary JSON value. + * + * You should usually call [Builder.dateConnected] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dateConnected(dateConnected: JsonField) = apply { + this.dateConnected = dateConnected + } + + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + fun gitAccountId(gitAccountId: String) = + gitAccountId(JsonField.of(gitAccountId)) + + /** + * Sets [Builder.gitAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitAccountId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun gitAccountId(gitAccountId: JsonField) = apply { + this.gitAccountId = gitAccountId + } + + fun gitId(gitId: Long) = gitId(JsonField.of(gitId)) + + /** + * Sets [Builder.gitId] to an arbitrary JSON value. + * + * You should usually call [Builder.gitId] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun gitId(gitId: JsonField) = apply { this.gitId = gitId } + + 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 private_(private_: Boolean) = private_(JsonField.of(private_)) + + /** + * Sets [Builder.private_] to an arbitrary JSON value. + * + * You should usually call [Builder.private_] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun private_(private_: JsonField) = apply { this.private_ = private_ } + + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun projectId(projectId: JsonField) = apply { + this.projectId = projectId + } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun branch(branch: String) = branch(JsonField.of(branch)) + + /** + * Sets [Builder.branch] to an arbitrary JSON value. + * + * You should usually call [Builder.branch] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun branch(branch: JsonField) = apply { this.branch = branch } + + fun rootDir(rootDir: String) = rootDir(JsonField.of(rootDir)) + + /** + * Sets [Builder.rootDir] to an arbitrary JSON value. + * + * You should usually call [Builder.rootDir] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun rootDir(rootDir: JsonField) = apply { this.rootDir = rootDir } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GitRepo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateConnected() + * .dateUpdated() + * .gitAccountId() + * .gitId() + * .name() + * .private_() + * .projectId() + * .slug() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GitRepo = + GitRepo( + checkRequired("id", id), + checkRequired("dateConnected", dateConnected), + checkRequired("dateUpdated", dateUpdated), + checkRequired("gitAccountId", gitAccountId), + checkRequired("gitId", gitId), + checkRequired("name", name), + checkRequired("private_", private_), + checkRequired("projectId", projectId), + checkRequired("slug", slug), + checkRequired("url", url), + branch, + rootDir, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GitRepo = apply { + if (validated) { + return@apply + } + + id() + dateConnected() + dateUpdated() + gitAccountId() + gitId() + name() + private_() + projectId() + slug() + url() + branch() + rootDir() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is GitRepo && id == other.id && dateConnected == other.dateConnected && dateUpdated == other.dateUpdated && gitAccountId == other.gitAccountId && gitId == other.gitId && name == other.name && private_ == other.private_ && projectId == other.projectId && slug == other.slug && url == other.url && branch == other.branch && rootDir == other.rootDir && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateConnected, dateUpdated, gitAccountId, gitId, name, private_, projectId, slug, url, branch, rootDir, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GitRepo{id=$id, dateConnected=$dateConnected, dateUpdated=$dateUpdated, gitAccountId=$gitAccountId, gitId=$gitId, name=$name, private_=$private_, projectId=$projectId, slug=$slug, url=$url, branch=$branch, rootDir=$rootDir, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Project && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && developmentGoalCount == other.developmentGoalCount && goalCount == other.goalCount && inferencePipelineCount == other.inferencePipelineCount && links == other.links && monitoringGoalCount == other.monitoringGoalCount && name == other.name && source == other.source && taskType == other.taskType && versionCount == other.versionCount && workspaceId == other.workspaceId && description == other.description && gitRepo == other.gitRepo && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, developmentGoalCount, goalCount, inferencePipelineCount, links, monitoringGoalCount, name, source, taskType, versionCount, workspaceId, description, gitRepo, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Project{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, developmentGoalCount=$developmentGoalCount, goalCount=$goalCount, inferencePipelineCount=$inferencePipelineCount, links=$links, monitoringGoalCount=$monitoringGoalCount, name=$name, source=$source, taskType=$taskType, versionCount=$versionCount, workspaceId=$workspaceId, description=$description, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + } + + class Workspace + private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") + @ExcludeMissing + creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException 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 dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException 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 dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException 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 inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException 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 memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException 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") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun periodEndDate(): Optional = + periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun periodStartDate(): Optional = + periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException 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 projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException 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 slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException 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 status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = + monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = + wildcardDomains.getOptional("wildcardDomains") + + /** + * 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 [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("creatorId") + @ExcludeMissing + fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inviteCount") + @ExcludeMissing + fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * 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 [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("inviteCode") + @ExcludeMissing + fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @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 [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + creatorId = workspace.creatorId + dateCreated = workspace.dateCreated + dateUpdated = workspace.dateUpdated + inviteCount = workspace.inviteCount + memberCount = workspace.memberCount + name = workspace.name + periodEndDate = workspace.periodEndDate + periodStartDate = workspace.periodStartDate + projectCount = workspace.projectCount + slug = workspace.slug + status = workspace.status + inviteCode = workspace.inviteCode + monthlyUsage = workspace.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspace.samlOnlyAccess + wildcardDomains = workspace.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + 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 } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = + dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun inviteCount(inviteCount: JsonField) = apply { + this.inviteCount = inviteCount + } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun memberCount(memberCount: JsonField) = apply { + this.memberCount = memberCount + } + + /** The workspace name. */ + 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 } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** + * Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. + */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun projectCount(projectCount: JsonField) = apply { + this.projectCount = projectCount + } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun inviteCode(inviteCode: JsonField) = apply { + this.inviteCode = inviteCode + } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = + samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @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 ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] 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 { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** + * An enum member indicating that [Status] 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) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + 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 OpenlayerInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $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 OpenlayerInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = + executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun predictionCount(): Optional = + predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @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 [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = + executionTimeMs(executionTimeMs as Long?) + + /** + * Alias for calling [Builder.executionTimeMs] with + * `executionTimeMs.orElse(null)`. + */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun monthYear(monthYear: JsonField) = apply { + this.monthYear = monthYear + } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is MonthlyUsage && executionTimeMs == other.executionTimeMs && monthYear == other.monthYear && predictionCount == other.predictionCount && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Workspace && id == other.id && creatorId == other.creatorId && dateCreated == other.dateCreated && dateUpdated == other.dateUpdated && inviteCount == other.inviteCount && memberCount == other.memberCount && name == other.name && periodEndDate == other.periodEndDate && periodStartDate == other.periodStartDate && projectCount == other.projectCount && slug == other.slug && status == other.status && inviteCode == other.inviteCode && monthlyUsage == other.monthlyUsage && samlOnlyAccess == other.samlOnlyAccess && wildcardDomains == other.wildcardDomains && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, creatorId, dateCreated, dateUpdated, inviteCount, memberCount, name, periodEndDate, periodStartDate, projectCount, slug, status, inviteCode, monthlyUsage, samlOnlyAccess, wildcardDomains, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Item && id == other.id && dateCreated == other.dateCreated && dateLastEvaluated == other.dateLastEvaluated && dateLastSampleReceived == other.dateLastSampleReceived && dateOfNextEvaluation == other.dateOfNextEvaluation && dateUpdated == other.dateUpdated && description == other.description && failingGoalCount == other.failingGoalCount && links == other.links && name == other.name && passingGoalCount == other.passingGoalCount && projectId == other.projectId && status == other.status && statusMessage == other.statusMessage && totalGoalCount == other.totalGoalCount && project == other.project && workspace == other.workspace && workspaceId == other.workspaceId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, dateCreated, dateLastEvaluated, dateLastSampleReceived, dateOfNextEvaluation, dateUpdated, description, failingGoalCount, links, name, passingGoalCount, projectId, status, statusMessage, totalGoalCount, project, workspace, workspaceId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, dateCreated=$dateCreated, dateLastEvaluated=$dateLastEvaluated, dateLastSampleReceived=$dateLastSampleReceived, dateOfNextEvaluation=$dateOfNextEvaluation, dateUpdated=$dateUpdated, description=$description, failingGoalCount=$failingGoalCount, links=$links, name=$name, passingGoalCount=$passingGoalCount, projectId=$projectId, status=$status, statusMessage=$statusMessage, totalGoalCount=$totalGoalCount, project=$project, workspace=$workspace, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InferencePipelineListResponse && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InferencePipelineListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateParams.kt similarity index 72% rename from openlayer-java-core/src/main/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateParams.kt rename to openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateParams.kt index e1d6917d..b4bde349 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateParams.kt @@ -1,55 +1,51 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.storage.presignedurl import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.Params +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers import com.openlayer.api.core.http.QueryParams import com.openlayer.api.core.toImmutable import java.util.Objects import java.util.Optional -class StoragePresignedUrlCreateParams -constructor( +/** Retrieve a presigned url to post storage artifacts. */ +class PresignedUrlCreateParams +private constructor( private val objectName: String, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, -) { +) : Params { + /** The name of the object. */ fun objectName(): String = objectName - fun _additionalHeaders(): Headers = additionalHeaders - - fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = additionalBodyProperties - @JvmSynthetic - internal fun getBody(): Optional> { - return Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - } - - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + fun _additionalHeaders(): Headers = additionalHeaders - @JvmSynthetic - internal fun getQueryParams(): QueryParams { - val queryParams = QueryParams.builder() - this.objectName.let { queryParams.put("objectName", listOf(it.toString())) } - queryParams.putAll(additionalQueryParams) - return queryParams.build() - } + fun _additionalQueryParams(): QueryParams = additionalQueryParams fun toBuilder() = Builder().from(this) companion object { + /** + * Returns a mutable builder for constructing an instance of [PresignedUrlCreateParams]. + * + * The following fields are required: + * ```java + * .objectName() + * ``` + */ @JvmStatic fun builder() = Builder() } - @NoAutoDetect - class Builder { + /** A builder for [PresignedUrlCreateParams]. */ + class Builder internal constructor() { private var objectName: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -57,15 +53,13 @@ constructor( private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(storagePresignedUrlCreateParams: StoragePresignedUrlCreateParams) = - apply { - objectName = storagePresignedUrlCreateParams.objectName - additionalHeaders = storagePresignedUrlCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = - storagePresignedUrlCreateParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - storagePresignedUrlCreateParams.additionalBodyProperties.toMutableMap() - } + internal fun from(presignedUrlCreateParams: PresignedUrlCreateParams) = apply { + objectName = presignedUrlCreateParams.objectName + additionalHeaders = presignedUrlCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = presignedUrlCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + presignedUrlCreateParams.additionalBodyProperties.toMutableMap() + } /** The name of the object. */ fun objectName(objectName: String) = apply { this.objectName = objectName } @@ -190,25 +184,50 @@ constructor( keys.forEach(::removeAdditionalBodyProperty) } - fun build(): StoragePresignedUrlCreateParams = - StoragePresignedUrlCreateParams( - checkNotNull(objectName) { "`objectName` is required but was not set" }, + /** + * Returns an immutable instance of [PresignedUrlCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .objectName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PresignedUrlCreateParams = + PresignedUrlCreateParams( + checkRequired("objectName", objectName), additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), ) } + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("objectName", objectName) + putAll(additionalQueryParams) + } + .build() + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is StoragePresignedUrlCreateParams && objectName == other.objectName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is PresignedUrlCreateParams && objectName == other.objectName && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int = /* spotless:off */ Objects.hash(objectName, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ override fun toString() = - "StoragePresignedUrlCreateParams{objectName=$objectName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "PresignedUrlCreateParams{objectName=$objectName, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt new file mode 100644 index 00000000..953cc735 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.storage.presignedurl + +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.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects + +class PresignedUrlCreateResponse +private constructor( + private val storageUri: JsonField, + private val url: JsonField, + private val fields: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("storageUri") + @ExcludeMissing + storageUri: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("fields") @ExcludeMissing fields: JsonValue = JsonMissing.of(), + ) : this(storageUri, url, fields, mutableMapOf()) + + /** + * The storage URI to send back to the backend after the upload was completed. + * + * @throws OpenlayerInvalidDataException 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 storageUri(): String = storageUri.getRequired("storageUri") + + /** + * The presigned url. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** Fields to include in the body of the upload. Only needed by s3 */ + @JsonProperty("fields") @ExcludeMissing fun _fields(): JsonValue = fields + + /** + * Returns the raw JSON value of [storageUri]. + * + * Unlike [storageUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("storageUri") @ExcludeMissing fun _storageUri(): JsonField = storageUri + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @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 [PresignedUrlCreateResponse]. + * + * The following fields are required: + * ```java + * .storageUri() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PresignedUrlCreateResponse]. */ + class Builder internal constructor() { + + private var storageUri: JsonField? = null + private var url: JsonField? = null + private var fields: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(presignedUrlCreateResponse: PresignedUrlCreateResponse) = apply { + storageUri = presignedUrlCreateResponse.storageUri + url = presignedUrlCreateResponse.url + fields = presignedUrlCreateResponse.fields + additionalProperties = presignedUrlCreateResponse.additionalProperties.toMutableMap() + } + + /** The storage URI to send back to the backend after the upload was completed. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** + * Sets [Builder.storageUri] to an arbitrary JSON value. + * + * You should usually call [Builder.storageUri] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The presigned url. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Fields to include in the body of the upload. Only needed by s3 */ + fun fields(fields: JsonValue) = apply { this.fields = fields } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PresignedUrlCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .storageUri() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PresignedUrlCreateResponse = + PresignedUrlCreateResponse( + checkRequired("storageUri", storageUri), + checkRequired("url", url), + fields, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PresignedUrlCreateResponse = apply { + if (validated) { + return@apply + } + + storageUri() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns 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 (storageUri.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PresignedUrlCreateResponse && storageUri == other.storageUri && url == other.url && fields == other.fields && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(storageUri, url, fields, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PresignedUrlCreateResponse{storageUri=$storageUri, url=$url, fields=$fields, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt index 2fbb5b68..e60e7d2f 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt @@ -2,9 +2,55 @@ package com.openlayer.api.services.async +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.commits.CommitRetrieveParams +import com.openlayer.api.models.commits.CommitRetrieveResponse import com.openlayer.api.services.async.commits.TestResultServiceAsync +import java.util.concurrent.CompletableFuture interface CommitServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun testResults(): TestResultServiceAsync + + /** Retrieve a project version (commit) by its id. */ + fun retrieve(params: CommitRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [CommitServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun testResults(): TestResultServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /versions/{projectVersionId}`, but is otherwise the + * same as [CommitServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + params: CommitRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt index 9fcf0d46..6195c624 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt @@ -3,17 +3,84 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.commits.CommitRetrieveParams +import com.openlayer.api.models.commits.CommitRetrieveResponse import com.openlayer.api.services.async.commits.TestResultServiceAsync import com.openlayer.api.services.async.commits.TestResultServiceAsyncImpl +import java.util.concurrent.CompletableFuture -class CommitServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : CommitServiceAsync { +class CommitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CommitServiceAsync { + + private val withRawResponse: CommitServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val testResults: TestResultServiceAsync by lazy { TestResultServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): CommitServiceAsync.WithRawResponse = withRawResponse + override fun testResults(): TestResultServiceAsync = testResults + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /versions/{projectVersionId} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommitServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val testResults: TestResultServiceAsync.WithRawResponse by lazy { + TestResultServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun testResults(): TestResultServiceAsync.WithRawResponse = testResults + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("versions", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt index 84e6d9ab..8b8bbd4e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt @@ -1,22 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineDeleteParams -import com.openlayer.api.models.InferencePipelineRetrieveParams -import com.openlayer.api.models.InferencePipelineRetrieveResponse -import com.openlayer.api.models.InferencePipelineUpdateParams -import com.openlayer.api.models.InferencePipelineUpdateResponse -import com.openlayer.api.services.async.inferencePipelines.DataServiceAsync -import com.openlayer.api.services.async.inferencePipelines.RowServiceAsync -import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsync +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateResponse +import com.openlayer.api.services.async.inferencepipelines.DataServiceAsync +import com.openlayer.api.services.async.inferencepipelines.RowServiceAsync +import com.openlayer.api.services.async.inferencepipelines.TestResultServiceAsync import java.util.concurrent.CompletableFuture interface InferencePipelineServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun data(): DataServiceAsync fun rows(): RowServiceAsync @@ -24,23 +30,97 @@ interface InferencePipelineServiceAsync { fun testResults(): TestResultServiceAsync /** Retrieve inference pipeline. */ - @JvmOverloads + fun retrieve( + params: InferencePipelineRetrieveParams + ): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: InferencePipelineRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Update inference pipeline. */ - @JvmOverloads + fun update( + params: InferencePipelineUpdateParams + ): CompletableFuture = update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: InferencePipelineUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** Delete inference pipeline. */ - @JvmOverloads + fun delete(params: InferencePipelineDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: InferencePipelineDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [InferencePipelineServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + fun data(): DataServiceAsync.WithRawResponse + + fun rows(): RowServiceAsync.WithRawResponse + + fun testResults(): TestResultServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /inference-pipelines/{inferencePipelineId}`, but is + * otherwise the same as [InferencePipelineServiceAsync.retrieve]. + */ + @MustBeClosed + fun retrieve( + params: InferencePipelineRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: InferencePipelineRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /inference-pipelines/{inferencePipelineId}`, but is + * otherwise the same as [InferencePipelineServiceAsync.update]. + */ + @MustBeClosed + fun update( + params: InferencePipelineUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete /inference-pipelines/{inferencePipelineId}`, but + * is otherwise the same as [InferencePipelineServiceAsync.delete]. + */ + @MustBeClosed + fun delete(params: InferencePipelineDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + params: InferencePipelineDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt index 62b8afb1..d333e5e9 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.emptyHandler import com.openlayer.api.core.handlers.errorHandler @@ -10,28 +11,31 @@ import com.openlayer.api.core.handlers.jsonHandler import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineDeleteParams -import com.openlayer.api.models.InferencePipelineRetrieveParams -import com.openlayer.api.models.InferencePipelineRetrieveResponse -import com.openlayer.api.models.InferencePipelineUpdateParams -import com.openlayer.api.models.InferencePipelineUpdateResponse -import com.openlayer.api.services.async.inferencePipelines.DataServiceAsync -import com.openlayer.api.services.async.inferencePipelines.DataServiceAsyncImpl -import com.openlayer.api.services.async.inferencePipelines.RowServiceAsync -import com.openlayer.api.services.async.inferencePipelines.RowServiceAsyncImpl -import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsync -import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsyncImpl +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateResponse +import com.openlayer.api.services.async.inferencepipelines.DataServiceAsync +import com.openlayer.api.services.async.inferencepipelines.DataServiceAsyncImpl +import com.openlayer.api.services.async.inferencepipelines.RowServiceAsync +import com.openlayer.api.services.async.inferencepipelines.RowServiceAsyncImpl +import com.openlayer.api.services.async.inferencepipelines.TestResultServiceAsync +import com.openlayer.api.services.async.inferencepipelines.TestResultServiceAsyncImpl import java.util.concurrent.CompletableFuture class InferencePipelineServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : InferencePipelineServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : InferencePipelineServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: InferencePipelineServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val data: DataServiceAsync by lazy { DataServiceAsyncImpl(clientOptions) } @@ -41,93 +45,138 @@ constructor( TestResultServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): InferencePipelineServiceAsync.WithRawResponse = withRawResponse + override fun data(): DataServiceAsync = data override fun rows(): RowServiceAsync = rows override fun testResults(): TestResultServiceAsync = testResults - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Retrieve inference pipeline. */ override fun retrieve( params: InferencePipelineRetrieveParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("inference-pipelines", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } + requestOptions: RequestOptions, + ): CompletableFuture = + // get /inference-pipelines/{inferencePipelineId} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Update inference pipeline. */ override fun update( params: InferencePipelineUpdateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("inference-pipelines", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // put /inference-pipelines/{inferencePipelineId} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: InferencePipelineDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /inference-pipelines/{inferencePipelineId} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InferencePipelineServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val data: DataServiceAsync.WithRawResponse by lazy { + DataServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val rows: RowServiceAsync.WithRawResponse by lazy { + RowServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val testResults: TestResultServiceAsync.WithRawResponse by lazy { + TestResultServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun data(): DataServiceAsync.WithRawResponse = data + + override fun rows(): RowServiceAsync.WithRawResponse = rows + + override fun testResults(): TestResultServiceAsync.WithRawResponse = testResults + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: InferencePipelineRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("inference-pipelines", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } - /** Delete inference pipeline. */ - override fun delete( - params: InferencePipelineDeleteParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("inference-pipelines", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response.use { deleteHandler.handle(it) } + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + + override fun delete( + params: InferencePipelineDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("inference-pipelines", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { response.use { deleteHandler.handle(it) } } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsync.kt index bc149ca9..8c47db0d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsync.kt @@ -1,35 +1,110 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.ProjectCreateParams -import com.openlayer.api.models.ProjectCreateResponse -import com.openlayer.api.models.ProjectListParams -import com.openlayer.api.models.ProjectListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.projects.ProjectCreateParams +import com.openlayer.api.models.projects.ProjectCreateResponse +import com.openlayer.api.models.projects.ProjectListParams +import com.openlayer.api.models.projects.ProjectListResponse import com.openlayer.api.services.async.projects.CommitServiceAsync import com.openlayer.api.services.async.projects.InferencePipelineServiceAsync import java.util.concurrent.CompletableFuture interface ProjectServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun commits(): CommitServiceAsync fun inferencePipelines(): InferencePipelineServiceAsync /** Create a project in your workspace. */ - @JvmOverloads + fun create(params: ProjectCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** List your workspace's projects. */ - @JvmOverloads + fun list(): CompletableFuture = list(ProjectListParams.none()) + + /** @see [list] */ fun list( - params: ProjectListParams, - requestOptions: RequestOptions = RequestOptions.none() + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + + /** @see [list] */ + fun list( + params: ProjectListParams = ProjectListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ProjectListParams.none(), requestOptions) + + /** + * A view of [ProjectServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun commits(): CommitServiceAsync.WithRawResponse + + fun inferencePipelines(): InferencePipelineServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /projects`, but is otherwise the same as + * [ProjectServiceAsync.create]. + */ + @MustBeClosed + fun create( + params: ProjectCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /projects`, but is otherwise the same as + * [ProjectServiceAsync.list]. + */ + @MustBeClosed + fun list(): CompletableFuture> = + list(ProjectListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ProjectListParams.none(), requestOptions) + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt index ac41df99..33b9d711 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,24 +11,26 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.ProjectCreateParams -import com.openlayer.api.models.ProjectCreateResponse -import com.openlayer.api.models.ProjectListParams -import com.openlayer.api.models.ProjectListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.projects.ProjectCreateParams +import com.openlayer.api.models.projects.ProjectCreateResponse +import com.openlayer.api.models.projects.ProjectListParams +import com.openlayer.api.models.projects.ProjectListResponse import com.openlayer.api.services.async.projects.CommitServiceAsync import com.openlayer.api.services.async.projects.CommitServiceAsyncImpl import com.openlayer.api.services.async.projects.InferencePipelineServiceAsync import com.openlayer.api.services.async.projects.InferencePipelineServiceAsyncImpl import java.util.concurrent.CompletableFuture -class ProjectServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectServiceAsync { +class ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val commits: CommitServiceAsync by lazy { CommitServiceAsyncImpl(clientOptions) } @@ -35,64 +38,101 @@ constructor( InferencePipelineServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): ProjectServiceAsync.WithRawResponse = withRawResponse + override fun commits(): CommitServiceAsync = commits override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Create a project in your workspace. */ override fun create( params: ProjectCreateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): CompletableFuture = + // post /projects + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /projects + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val commits: CommitServiceAsync.WithRawResponse by lazy { + CommitServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val inferencePipelines: InferencePipelineServiceAsync.WithRawResponse by lazy { + InferencePipelineServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun commits(): CommitServiceAsync.WithRawResponse = commits + + override fun inferencePipelines(): InferencePipelineServiceAsync.WithRawResponse = + inferencePipelines + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** List your workspace's projects. */ - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("projects") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsync.kt index 2030c4a0..c5211be6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsync.kt @@ -6,5 +6,18 @@ import com.openlayer.api.services.async.storage.PresignedUrlServiceAsync interface StorageServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun presignedUrl(): PresignedUrlServiceAsync + + /** + * A view of [StorageServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + fun presignedUrl(): PresignedUrlServiceAsync.WithRawResponse + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsyncImpl.kt index 088fa251..a1edb561 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/StorageServiceAsyncImpl.kt @@ -6,14 +6,28 @@ import com.openlayer.api.core.ClientOptions import com.openlayer.api.services.async.storage.PresignedUrlServiceAsync import com.openlayer.api.services.async.storage.PresignedUrlServiceAsyncImpl -class StorageServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : StorageServiceAsync { +class StorageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + StorageServiceAsync { + + private val withRawResponse: StorageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val presignedUrl: PresignedUrlServiceAsync by lazy { PresignedUrlServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): StorageServiceAsync.WithRawResponse = withRawResponse + override fun presignedUrl(): PresignedUrlServiceAsync = presignedUrl + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StorageServiceAsync.WithRawResponse { + + private val presignedUrl: PresignedUrlServiceAsync.WithRawResponse by lazy { + PresignedUrlServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun presignedUrl(): PresignedUrlServiceAsync.WithRawResponse = presignedUrl + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsync.kt index dde3ea27..40c54d7b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async.commits +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.CommitTestResultListParams -import com.openlayer.api.models.CommitTestResultListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.commits.testresults.TestResultListParams +import com.openlayer.api.models.commits.testresults.TestResultListResponse import java.util.concurrent.CompletableFuture interface TestResultServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** List the test results for a project commit (project version). */ - @JvmOverloads + fun list(params: TestResultListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( - params: CommitTestResultListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [TestResultServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /versions/{projectVersionId}/results`, but is + * otherwise the same as [TestResultServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: TestResultListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt index 9c554b1c..8163f596 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.commits import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,43 +11,60 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.CommitTestResultListParams -import com.openlayer.api.models.CommitTestResultListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.commits.testresults.TestResultListParams +import com.openlayer.api.models.commits.testresults.TestResultListResponse import java.util.concurrent.CompletableFuture -class TestResultServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : TestResultServiceAsync { +class TestResultServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TestResultServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TestResultServiceAsync.WithRawResponse = withRawResponse - /** List the test results for a project commit (project version). */ override fun list( - params: CommitTestResultListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("versions", params.getPathParam(0), "results") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: TestResultListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /versions/{projectVersionId}/results + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TestResultListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("versions", params._pathParam(0), "results") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/DataServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/DataServiceAsync.kt deleted file mode 100644 index 4f079ecb..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/DataServiceAsync.kt +++ /dev/null @@ -1,20 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.openlayer.api.services.async.inferencePipelines - -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineDataStreamParams -import com.openlayer.api.models.InferencePipelineDataStreamResponse -import java.util.concurrent.CompletableFuture - -interface DataServiceAsync { - - /** Publish an inference data point to an inference pipeline. */ - @JvmOverloads - fun stream( - params: InferencePipelineDataStreamParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/DataServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/DataServiceAsyncImpl.kt deleted file mode 100644 index cc3c822f..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/DataServiceAsyncImpl.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.async.inferencePipelines - -import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineDataStreamParams -import com.openlayer.api.models.InferencePipelineDataStreamResponse -import java.util.concurrent.CompletableFuture - -class DataServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : DataServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val streamHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Publish an inference data point to an inference pipeline. */ - override fun stream( - params: InferencePipelineDataStreamParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("inference-pipelines", params.getPathParam(0), "data-stream") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { streamHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt deleted file mode 100644 index 4522c37c..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt +++ /dev/null @@ -1,20 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.openlayer.api.services.async.inferencePipelines - -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineRowUpdateParams -import com.openlayer.api.models.InferencePipelineRowUpdateResponse -import java.util.concurrent.CompletableFuture - -interface RowServiceAsync { - - /** Update an inference data point in an inference pipeline. */ - @JvmOverloads - fun update( - params: InferencePipelineRowUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt deleted file mode 100644 index a54c2680..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.async.inferencePipelines - -import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineRowUpdateParams -import com.openlayer.api.models.InferencePipelineRowUpdateResponse -import java.util.concurrent.CompletableFuture - -class RowServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : RowServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Update an inference data point in an inference pipeline. */ - override fun update( - params: InferencePipelineRowUpdateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("inference-pipelines", params.getPathParam(0), "rows") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/TestResultServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/TestResultServiceAsync.kt deleted file mode 100644 index 5d526af0..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/TestResultServiceAsync.kt +++ /dev/null @@ -1,20 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.openlayer.api.services.async.inferencePipelines - -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineTestResultListParams -import com.openlayer.api.models.InferencePipelineTestResultListResponse -import java.util.concurrent.CompletableFuture - -interface TestResultServiceAsync { - - /** List the latest test results for an inference pipeline. */ - @JvmOverloads - fun list( - params: InferencePipelineTestResultListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt deleted file mode 100644 index 2474a456..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.async.inferencePipelines - -import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineTestResultListParams -import com.openlayer.api.models.InferencePipelineTestResultListResponse -import java.util.concurrent.CompletableFuture - -class TestResultServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : TestResultServiceAsync { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** List the latest test results for an inference pipeline. */ - override fun list( - params: InferencePipelineTestResultListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("inference-pipelines", params.getPathParam(0), "results") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsync.kt new file mode 100644 index 00000000..6e1b9d85 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsync.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse +import java.util.concurrent.CompletableFuture + +interface DataServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** Publish an inference data point to an inference pipeline. */ + fun stream(params: DataStreamParams): CompletableFuture = + stream(params, RequestOptions.none()) + + /** @see [stream] */ + fun stream( + params: DataStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [DataServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post + * /inference-pipelines/{inferencePipelineId}/data-stream`, but is otherwise the same as + * [DataServiceAsync.stream]. + */ + @MustBeClosed + fun stream( + params: DataStreamParams + ): CompletableFuture> = + stream(params, RequestOptions.none()) + + /** @see [stream] */ + @MustBeClosed + fun stream( + params: DataStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt new file mode 100644 index 00000000..b3614235 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse +import java.util.concurrent.CompletableFuture + +class DataServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DataServiceAsync { + + private val withRawResponse: DataServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DataServiceAsync.WithRawResponse = withRawResponse + + override fun stream( + params: DataStreamParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /inference-pipelines/{inferencePipelineId}/data-stream + withRawResponse().stream(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DataServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val streamHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun stream( + params: DataStreamParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("inference-pipelines", params._pathParam(0), "data-stream") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { streamHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt new file mode 100644 index 00000000..80de582d --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse +import java.util.concurrent.CompletableFuture + +interface RowServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** Update an inference data point in an inference pipeline. */ + fun update(params: RowUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + params: RowUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [RowServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `put /inference-pipelines/{inferencePipelineId}/rows`, + * but is otherwise the same as [RowServiceAsync.update]. + */ + @MustBeClosed + fun update(params: RowUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + params: RowUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt new file mode 100644 index 00000000..50b06e66 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse +import java.util.concurrent.CompletableFuture + +class RowServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RowServiceAsync { + + private val withRawResponse: RowServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RowServiceAsync.WithRawResponse = withRawResponse + + override fun update( + params: RowUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /inference-pipelines/{inferencePipelineId}/rows + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RowServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: RowUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params._pathParam(0), "rows") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsync.kt new file mode 100644 index 00000000..dcb258fc --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsync.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListResponse +import java.util.concurrent.CompletableFuture + +interface TestResultServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** List the latest test results for an inference pipeline. */ + fun list(params: TestResultListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [TestResultServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /inference-pipelines/{inferencePipelineId}/results`, + * but is otherwise the same as [TestResultServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: TestResultListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt new file mode 100644 index 00000000..c0ea06fa --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListResponse +import java.util.concurrent.CompletableFuture + +class TestResultServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultServiceAsync { + + private val withRawResponse: TestResultServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TestResultServiceAsync.WithRawResponse = withRawResponse + + override fun list( + params: TestResultListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /inference-pipelines/{inferencePipelineId}/results + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TestResultListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("inference-pipelines", params._pathParam(0), "results") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt index e10cd5c0..93c8603b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt @@ -1,29 +1,78 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async.projects +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.ProjectCommitCreateParams -import com.openlayer.api.models.ProjectCommitCreateResponse -import com.openlayer.api.models.ProjectCommitListParams -import com.openlayer.api.models.ProjectCommitListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.projects.commits.CommitCreateParams +import com.openlayer.api.models.projects.commits.CommitCreateResponse +import com.openlayer.api.models.projects.commits.CommitListParams +import com.openlayer.api.models.projects.commits.CommitListResponse import java.util.concurrent.CompletableFuture interface CommitServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Create a new commit (project version) in a project. */ - @JvmOverloads + fun create(params: CommitCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( - params: ProjectCommitCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + params: CommitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** List the commits (project versions) in a project. */ - @JvmOverloads + fun list(params: CommitListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( - params: ProjectCommitListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + params: CommitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [CommitServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /projects/{projectId}/versions`, but is otherwise + * the same as [CommitServiceAsync.create]. + */ + @MustBeClosed + fun create( + params: CommitCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: CommitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /projects/{projectId}/versions`, but is otherwise + * the same as [CommitServiceAsync.list]. + */ + @MustBeClosed + fun list(params: CommitListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: CommitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt index b0440f48..0558d15b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,77 +11,100 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.ProjectCommitCreateParams -import com.openlayer.api.models.ProjectCommitCreateResponse -import com.openlayer.api.models.ProjectCommitListParams -import com.openlayer.api.models.ProjectCommitListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.projects.commits.CommitCreateParams +import com.openlayer.api.models.projects.commits.CommitCreateResponse +import com.openlayer.api.models.projects.commits.CommitListParams +import com.openlayer.api.models.projects.commits.CommitListResponse import java.util.concurrent.CompletableFuture -class CommitServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : CommitServiceAsync { +class CommitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CommitServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CommitServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CommitServiceAsync.WithRawResponse = withRawResponse - /** Create a new commit (project version) in a project. */ override fun create( - params: ProjectCommitCreateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects", params.getPathParam(0), "versions") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: CommitCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /projects/{projectId}/versions + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CommitListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /projects/{projectId}/versions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommitServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: CommitCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects", params._pathParam(0), "versions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - /** List the commits (project versions) in a project. */ - override fun list( - params: ProjectCommitListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("projects", params.getPathParam(0), "versions") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: CommitListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects", params._pathParam(0), "versions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsync.kt index a0a6c636..b219a00c 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsync.kt @@ -1,29 +1,83 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async.projects +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.ProjectInferencePipelineCreateParams -import com.openlayer.api.models.ProjectInferencePipelineCreateResponse -import com.openlayer.api.models.ProjectInferencePipelineListParams -import com.openlayer.api.models.ProjectInferencePipelineListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateResponse +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListResponse import java.util.concurrent.CompletableFuture interface InferencePipelineServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Create an inference pipeline in a project. */ - @JvmOverloads fun create( - params: ProjectInferencePipelineCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + params: InferencePipelineCreateParams + ): CompletableFuture = create(params, RequestOptions.none()) + + /** @see [create] */ + fun create( + params: InferencePipelineCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture /** List the inference pipelines in a project. */ - @JvmOverloads fun list( - params: ProjectInferencePipelineListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + params: InferencePipelineListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [InferencePipelineServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /projects/{projectId}/inference-pipelines`, but is + * otherwise the same as [InferencePipelineServiceAsync.create]. + */ + @MustBeClosed + fun create( + params: InferencePipelineCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: InferencePipelineCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /projects/{projectId}/inference-pipelines`, but is + * otherwise the same as [InferencePipelineServiceAsync.list]. + */ + @MustBeClosed + fun list( + params: InferencePipelineListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt index e02d1237..eebe0dcb 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,77 +11,101 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.ProjectInferencePipelineCreateParams -import com.openlayer.api.models.ProjectInferencePipelineCreateResponse -import com.openlayer.api.models.ProjectInferencePipelineListParams -import com.openlayer.api.models.ProjectInferencePipelineListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateResponse +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListResponse import java.util.concurrent.CompletableFuture class InferencePipelineServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : InferencePipelineServiceAsync { +internal constructor(private val clientOptions: ClientOptions) : InferencePipelineServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: InferencePipelineServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): InferencePipelineServiceAsync.WithRawResponse = withRawResponse - /** Create an inference pipeline in a project. */ override fun create( - params: ProjectInferencePipelineCreateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects", params.getPathParam(0), "inference-pipelines") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: InferencePipelineCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /projects/{projectId}/inference-pipelines + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /projects/{projectId}/inference-pipelines + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InferencePipelineServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: InferencePipelineCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects", params._pathParam(0), "inference-pipelines") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** List the inference pipelines in a project. */ - override fun list( - params: ProjectInferencePipelineListParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("projects", params.getPathParam(0), "inference-pipelines") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects", params._pathParam(0), "inference-pipelines") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsync.kt index 933abd81..d662d529 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsync.kt @@ -1,20 +1,52 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async.storage +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.StoragePresignedUrlCreateParams -import com.openlayer.api.models.StoragePresignedUrlCreateResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateResponse import java.util.concurrent.CompletableFuture interface PresignedUrlServiceAsync { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve a presigned url to post storage artifacts. */ - @JvmOverloads + fun create(params: PresignedUrlCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( - params: StoragePresignedUrlCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture + params: PresignedUrlCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [PresignedUrlServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /storage/presigned-url`, but is otherwise the same + * as [PresignedUrlServiceAsync.create]. + */ + @MustBeClosed + fun create( + params: PresignedUrlCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: PresignedUrlCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt index 89153fde..eef0b53d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.storage import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,45 +11,62 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.StoragePresignedUrlCreateParams -import com.openlayer.api.models.StoragePresignedUrlCreateResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateResponse import java.util.concurrent.CompletableFuture -class PresignedUrlServiceAsyncImpl -constructor( - private val clientOptions: ClientOptions, -) : PresignedUrlServiceAsync { +class PresignedUrlServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PresignedUrlServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PresignedUrlServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): PresignedUrlServiceAsync.WithRawResponse = withRawResponse - /** Retrieve a presigned url to post storage artifacts. */ override fun create( - params: StoragePresignedUrlCreateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("storage", "presigned-url") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: PresignedUrlCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /storage/presigned-url + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PresignedUrlServiceAsync.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: PresignedUrlCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("storage", "presigned-url") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt index 6c803869..704d2114 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt @@ -2,9 +2,50 @@ package com.openlayer.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.commits.CommitRetrieveParams +import com.openlayer.api.models.commits.CommitRetrieveResponse import com.openlayer.api.services.blocking.commits.TestResultService interface CommitService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun testResults(): TestResultService + + /** Retrieve a project version (commit) by its id. */ + fun retrieve(params: CommitRetrieveParams): CommitRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitRetrieveResponse + + /** A view of [CommitService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun testResults(): TestResultService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /versions/{projectVersionId}`, but is otherwise the + * same as [CommitService.retrieve]. + */ + @MustBeClosed + fun retrieve(params: CommitRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt index 50222a85..98799c85 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt @@ -3,15 +3,78 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.commits.CommitRetrieveParams +import com.openlayer.api.models.commits.CommitRetrieveResponse import com.openlayer.api.services.blocking.commits.TestResultService import com.openlayer.api.services.blocking.commits.TestResultServiceImpl -class CommitServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : CommitService { +class CommitServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CommitService { + + private val withRawResponse: CommitService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val testResults: TestResultService by lazy { TestResultServiceImpl(clientOptions) } + override fun withRawResponse(): CommitService.WithRawResponse = withRawResponse + override fun testResults(): TestResultService = testResults + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): CommitRetrieveResponse = + // get /versions/{projectVersionId} + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommitService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val testResults: TestResultService.WithRawResponse by lazy { + TestResultServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun testResults(): TestResultService.WithRawResponse = testResults + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: CommitRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("versions", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt index 8b22b537..bf82c1f1 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt @@ -1,21 +1,27 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineDeleteParams -import com.openlayer.api.models.InferencePipelineRetrieveParams -import com.openlayer.api.models.InferencePipelineRetrieveResponse -import com.openlayer.api.models.InferencePipelineUpdateParams -import com.openlayer.api.models.InferencePipelineUpdateResponse -import com.openlayer.api.services.blocking.inferencePipelines.DataService -import com.openlayer.api.services.blocking.inferencePipelines.RowService -import com.openlayer.api.services.blocking.inferencePipelines.TestResultService +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateResponse +import com.openlayer.api.services.blocking.inferencepipelines.DataService +import com.openlayer.api.services.blocking.inferencepipelines.RowService +import com.openlayer.api.services.blocking.inferencepipelines.TestResultService interface InferencePipelineService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun data(): DataService fun rows(): RowService @@ -23,23 +29,92 @@ interface InferencePipelineService { fun testResults(): TestResultService /** Retrieve inference pipeline. */ - @JvmOverloads + fun retrieve(params: InferencePipelineRetrieveParams): InferencePipelineRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ fun retrieve( params: InferencePipelineRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): InferencePipelineRetrieveResponse /** Update inference pipeline. */ - @JvmOverloads + fun update(params: InferencePipelineUpdateParams): InferencePipelineUpdateResponse = + update(params, RequestOptions.none()) + + /** @see [update] */ fun update( params: InferencePipelineUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): InferencePipelineUpdateResponse /** Delete inference pipeline. */ - @JvmOverloads + fun delete(params: InferencePipelineDeleteParams) = delete(params, RequestOptions.none()) + + /** @see [delete] */ fun delete( params: InferencePipelineDeleteParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ) + + /** + * A view of [InferencePipelineService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + fun data(): DataService.WithRawResponse + + fun rows(): RowService.WithRawResponse + + fun testResults(): TestResultService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /inference-pipelines/{inferencePipelineId}`, but is + * otherwise the same as [InferencePipelineService.retrieve]. + */ + @MustBeClosed + fun retrieve( + params: InferencePipelineRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: InferencePipelineRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /inference-pipelines/{inferencePipelineId}`, but is + * otherwise the same as [InferencePipelineService.update]. + */ + @MustBeClosed + fun update( + params: InferencePipelineUpdateParams + ): HttpResponseFor = update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete /inference-pipelines/{inferencePipelineId}`, but + * is otherwise the same as [InferencePipelineService.delete]. + */ + @MustBeClosed + fun delete(params: InferencePipelineDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + params: InferencePipelineDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt index 40eb3ee1..d2b9adbb 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.emptyHandler import com.openlayer.api.core.handlers.errorHandler @@ -10,27 +11,30 @@ import com.openlayer.api.core.handlers.jsonHandler import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineDeleteParams -import com.openlayer.api.models.InferencePipelineRetrieveParams -import com.openlayer.api.models.InferencePipelineRetrieveResponse -import com.openlayer.api.models.InferencePipelineUpdateParams -import com.openlayer.api.models.InferencePipelineUpdateResponse -import com.openlayer.api.services.blocking.inferencePipelines.DataService -import com.openlayer.api.services.blocking.inferencePipelines.DataServiceImpl -import com.openlayer.api.services.blocking.inferencePipelines.RowService -import com.openlayer.api.services.blocking.inferencePipelines.RowServiceImpl -import com.openlayer.api.services.blocking.inferencePipelines.TestResultService -import com.openlayer.api.services.blocking.inferencePipelines.TestResultServiceImpl - -class InferencePipelineServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : InferencePipelineService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateResponse +import com.openlayer.api.services.blocking.inferencepipelines.DataService +import com.openlayer.api.services.blocking.inferencepipelines.DataServiceImpl +import com.openlayer.api.services.blocking.inferencepipelines.RowService +import com.openlayer.api.services.blocking.inferencepipelines.RowServiceImpl +import com.openlayer.api.services.blocking.inferencepipelines.TestResultService +import com.openlayer.api.services.blocking.inferencepipelines.TestResultServiceImpl + +class InferencePipelineServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InferencePipelineService { + + private val withRawResponse: InferencePipelineService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val data: DataService by lazy { DataServiceImpl(clientOptions) } @@ -38,87 +42,127 @@ constructor( private val testResults: TestResultService by lazy { TestResultServiceImpl(clientOptions) } + override fun withRawResponse(): InferencePipelineService.WithRawResponse = withRawResponse + override fun data(): DataService = data override fun rows(): RowService = rows override fun testResults(): TestResultService = testResults - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Retrieve inference pipeline. */ override fun retrieve( params: InferencePipelineRetrieveParams, - requestOptions: RequestOptions - ): InferencePipelineRetrieveResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("inference-pipelines", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { retrieveHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } + requestOptions: RequestOptions, + ): InferencePipelineRetrieveResponse = + // get /inference-pipelines/{inferencePipelineId} + withRawResponse().retrieve(params, requestOptions).parse() - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Update inference pipeline. */ override fun update( params: InferencePipelineUpdateParams, - requestOptions: RequestOptions - ): InferencePipelineUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("inference-pipelines", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): InferencePipelineUpdateResponse = + // put /inference-pipelines/{inferencePipelineId} + withRawResponse().update(params, requestOptions).parse() + + override fun delete(params: InferencePipelineDeleteParams, requestOptions: RequestOptions) { + // delete /inference-pipelines/{inferencePipelineId} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InferencePipelineService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val data: DataService.WithRawResponse by lazy { + DataServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val rows: RowService.WithRawResponse by lazy { + RowServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val testResults: TestResultService.WithRawResponse by lazy { + TestResultServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun data(): DataService.WithRawResponse = data + + override fun rows(): RowService.WithRawResponse = rows + + override fun testResults(): TestResultService.WithRawResponse = testResults + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun retrieve( + params: InferencePipelineRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("inference-pipelines", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } - } - private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } - /** Delete inference pipeline. */ - override fun delete(params: InferencePipelineDeleteParams, requestOptions: RequestOptions) { - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .addPathSegments("inference-pipelines", params.getPathParam(0)) - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - clientOptions.httpClient.execute(request, requestOptions).let { response -> - response.use { deleteHandler.handle(it) } + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) + + override fun delete( + params: InferencePipelineDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .addPathSegments("inference-pipelines", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { response.use { deleteHandler.handle(it) } } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectService.kt index a9e58d1d..e88bd15b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectService.kt @@ -1,34 +1,100 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.ProjectCreateParams -import com.openlayer.api.models.ProjectCreateResponse -import com.openlayer.api.models.ProjectListParams -import com.openlayer.api.models.ProjectListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.projects.ProjectCreateParams +import com.openlayer.api.models.projects.ProjectCreateResponse +import com.openlayer.api.models.projects.ProjectListParams +import com.openlayer.api.models.projects.ProjectListResponse import com.openlayer.api.services.blocking.projects.CommitService import com.openlayer.api.services.blocking.projects.InferencePipelineService interface ProjectService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun commits(): CommitService fun inferencePipelines(): InferencePipelineService /** Create a project in your workspace. */ - @JvmOverloads + fun create(params: ProjectCreateParams): ProjectCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( params: ProjectCreateParams, - requestOptions: RequestOptions = RequestOptions.none() + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectCreateResponse /** List your workspace's projects. */ - @JvmOverloads + fun list(): ProjectListResponse = list(ProjectListParams.none()) + + /** @see [list] */ fun list( - params: ProjectListParams, - requestOptions: RequestOptions = RequestOptions.none() + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): ProjectListResponse + + /** @see [list] */ + fun list(params: ProjectListParams = ProjectListParams.none()): ProjectListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(requestOptions: RequestOptions): ProjectListResponse = + list(ProjectListParams.none(), requestOptions) + + /** A view of [ProjectService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun commits(): CommitService.WithRawResponse + + fun inferencePipelines(): InferencePipelineService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /projects`, but is otherwise the same as + * [ProjectService.create]. + */ + @MustBeClosed + fun create(params: ProjectCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /projects`, but is otherwise the same as + * [ProjectService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(ProjectListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: ProjectListParams = ProjectListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ProjectListParams.none(), requestOptions) + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt index b90d15a5..354e63f8 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,23 +11,25 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.ProjectCreateParams -import com.openlayer.api.models.ProjectCreateResponse -import com.openlayer.api.models.ProjectListParams -import com.openlayer.api.models.ProjectListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.projects.ProjectCreateParams +import com.openlayer.api.models.projects.ProjectCreateResponse +import com.openlayer.api.models.projects.ProjectListParams +import com.openlayer.api.models.projects.ProjectListResponse import com.openlayer.api.services.blocking.projects.CommitService import com.openlayer.api.services.blocking.projects.CommitServiceImpl import com.openlayer.api.services.blocking.projects.InferencePipelineService import com.openlayer.api.services.blocking.projects.InferencePipelineServiceImpl -class ProjectServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : ProjectService { +class ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: ProjectService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val commits: CommitService by lazy { CommitServiceImpl(clientOptions) } @@ -34,64 +37,97 @@ constructor( InferencePipelineServiceImpl(clientOptions) } + override fun withRawResponse(): ProjectService.WithRawResponse = withRawResponse + override fun commits(): CommitService = commits override fun inferencePipelines(): InferencePipelineService = inferencePipelines - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Create a project in your workspace. */ override fun create( params: ProjectCreateParams, - requestOptions: RequestOptions - ): ProjectCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + requestOptions: RequestOptions, + ): ProjectCreateResponse = + // post /projects + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): ProjectListResponse = + // get /projects + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProjectService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val commits: CommitService.WithRawResponse by lazy { + CommitServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val inferencePipelines: InferencePipelineService.WithRawResponse by lazy { + InferencePipelineServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun commits(): CommitService.WithRawResponse = commits + + override fun inferencePipelines(): InferencePipelineService.WithRawResponse = + inferencePipelines + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: ProjectCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** List your workspace's projects. */ - override fun list( - params: ProjectListParams, - requestOptions: RequestOptions - ): ProjectListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("projects") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageService.kt index 20ae29ab..2302938e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageService.kt @@ -6,5 +6,16 @@ import com.openlayer.api.services.blocking.storage.PresignedUrlService interface StorageService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + fun presignedUrl(): PresignedUrlService + + /** A view of [StorageService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + fun presignedUrl(): PresignedUrlService.WithRawResponse + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageServiceImpl.kt index f33a55fc..f9a80210 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/StorageServiceImpl.kt @@ -6,12 +6,26 @@ import com.openlayer.api.core.ClientOptions import com.openlayer.api.services.blocking.storage.PresignedUrlService import com.openlayer.api.services.blocking.storage.PresignedUrlServiceImpl -class StorageServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : StorageService { +class StorageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + StorageService { + + private val withRawResponse: StorageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } private val presignedUrl: PresignedUrlService by lazy { PresignedUrlServiceImpl(clientOptions) } + override fun withRawResponse(): StorageService.WithRawResponse = withRawResponse + override fun presignedUrl(): PresignedUrlService = presignedUrl + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + StorageService.WithRawResponse { + + private val presignedUrl: PresignedUrlService.WithRawResponse by lazy { + PresignedUrlServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun presignedUrl(): PresignedUrlService.WithRawResponse = presignedUrl + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultService.kt index 5ad32eff..3119ffe4 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultService.kt @@ -1,19 +1,46 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking.commits +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.CommitTestResultListParams -import com.openlayer.api.models.CommitTestResultListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.commits.testresults.TestResultListParams +import com.openlayer.api.models.commits.testresults.TestResultListResponse interface TestResultService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** List the test results for a project commit (project version). */ - @JvmOverloads + fun list(params: TestResultListParams): TestResultListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( - params: CommitTestResultListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CommitTestResultListResponse + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TestResultListResponse + + /** A view of [TestResultService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /versions/{projectVersionId}/results`, but is + * otherwise the same as [TestResultService.list]. + */ + @MustBeClosed + fun list(params: TestResultListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt index 272c1f56..2a5a5e91 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.commits import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,43 +11,58 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.CommitTestResultListParams -import com.openlayer.api.models.CommitTestResultListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.commits.testresults.TestResultListParams +import com.openlayer.api.models.commits.testresults.TestResultListResponse -class TestResultServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : TestResultService { +class TestResultServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: TestResultService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): TestResultService.WithRawResponse = withRawResponse - /** List the test results for a project commit (project version). */ override fun list( - params: CommitTestResultListParams, - requestOptions: RequestOptions - ): CommitTestResultListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("versions", params.getPathParam(0), "results") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: TestResultListParams, + requestOptions: RequestOptions, + ): TestResultListResponse = + // get /versions/{projectVersionId}/results + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TestResultListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("versions", params._pathParam(0), "results") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataService.kt deleted file mode 100644 index bbfd2cf2..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataService.kt +++ /dev/null @@ -1,19 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineDataStreamParams -import com.openlayer.api.models.InferencePipelineDataStreamResponse - -interface DataService { - - /** Publish an inference data point to an inference pipeline. */ - @JvmOverloads - fun stream( - params: InferencePipelineDataStreamParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InferencePipelineDataStreamResponse -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataServiceImpl.kt deleted file mode 100644 index b3309310..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataServiceImpl.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineDataStreamParams -import com.openlayer.api.models.InferencePipelineDataStreamResponse - -class DataServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : DataService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val streamHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Publish an inference data point to an inference pipeline. */ - override fun stream( - params: InferencePipelineDataStreamParams, - requestOptions: RequestOptions - ): InferencePipelineDataStreamResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("inference-pipelines", params.getPathParam(0), "data-stream") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { streamHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt deleted file mode 100644 index 3548f85b..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt +++ /dev/null @@ -1,19 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineRowUpdateParams -import com.openlayer.api.models.InferencePipelineRowUpdateResponse - -interface RowService { - - /** Update an inference data point in an inference pipeline. */ - @JvmOverloads - fun update( - params: InferencePipelineRowUpdateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InferencePipelineRowUpdateResponse -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt deleted file mode 100644 index 537d7dac..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineRowUpdateParams -import com.openlayer.api.models.InferencePipelineRowUpdateResponse - -class RowServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : RowService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** Update an inference data point in an inference pipeline. */ - override fun update( - params: InferencePipelineRowUpdateParams, - requestOptions: RequestOptions - ): InferencePipelineRowUpdateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .addPathSegments("inference-pipelines", params.getPathParam(0), "rows") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { updateHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultService.kt deleted file mode 100644 index 24e0ca56..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultService.kt +++ /dev/null @@ -1,19 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.InferencePipelineTestResultListParams -import com.openlayer.api.models.InferencePipelineTestResultListResponse - -interface TestResultService { - - /** List the latest test results for an inference pipeline. */ - @JvmOverloads - fun list( - params: InferencePipelineTestResultListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): InferencePipelineTestResultListResponse -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultServiceImpl.kt deleted file mode 100644 index ac767530..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultServiceImpl.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.InferencePipelineTestResultListParams -import com.openlayer.api.models.InferencePipelineTestResultListResponse - -class TestResultServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : TestResultService { - - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) - - /** List the latest test results for an inference pipeline. */ - override fun list( - params: InferencePipelineTestResultListParams, - requestOptions: RequestOptions - ): InferencePipelineTestResultListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("inference-pipelines", params.getPathParam(0), "results") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataService.kt new file mode 100644 index 00000000..ba3abb66 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataService.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse + +interface DataService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** Publish an inference data point to an inference pipeline. */ + fun stream(params: DataStreamParams): DataStreamResponse = stream(params, RequestOptions.none()) + + /** @see [stream] */ + fun stream( + params: DataStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DataStreamResponse + + /** A view of [DataService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post + * /inference-pipelines/{inferencePipelineId}/data-stream`, but is otherwise the same as + * [DataService.stream]. + */ + @MustBeClosed + fun stream(params: DataStreamParams): HttpResponseFor = + stream(params, RequestOptions.none()) + + /** @see [stream] */ + @MustBeClosed + fun stream( + params: DataStreamParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt new file mode 100644 index 00000000..2f1b4e10 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams +import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse + +class DataServiceImpl internal constructor(private val clientOptions: ClientOptions) : DataService { + + private val withRawResponse: DataService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DataService.WithRawResponse = withRawResponse + + override fun stream( + params: DataStreamParams, + requestOptions: RequestOptions, + ): DataStreamResponse = + // post /inference-pipelines/{inferencePipelineId}/data-stream + withRawResponse().stream(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DataService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val streamHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun stream( + params: DataStreamParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("inference-pipelines", params._pathParam(0), "data-stream") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { streamHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt new file mode 100644 index 00000000..d77752c7 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse + +interface RowService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** Update an inference data point in an inference pipeline. */ + fun update(params: RowUpdateParams): RowUpdateResponse = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + params: RowUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RowUpdateResponse + + /** A view of [RowService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `put /inference-pipelines/{inferencePipelineId}/rows`, + * but is otherwise the same as [RowService.update]. + */ + @MustBeClosed + fun update(params: RowUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + params: RowUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt new file mode 100644 index 00000000..0762fdb9 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse + +class RowServiceImpl internal constructor(private val clientOptions: ClientOptions) : RowService { + + private val withRawResponse: RowService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RowService.WithRawResponse = withRawResponse + + override fun update( + params: RowUpdateParams, + requestOptions: RequestOptions, + ): RowUpdateResponse = + // put /inference-pipelines/{inferencePipelineId}/rows + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RowService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + override fun update( + params: RowUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params._pathParam(0), "rows") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultService.kt new file mode 100644 index 00000000..45dae6c1 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultService.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListResponse + +interface TestResultService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** List the latest test results for an inference pipeline. */ + fun list(params: TestResultListParams): TestResultListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TestResultListResponse + + /** A view of [TestResultService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `get /inference-pipelines/{inferencePipelineId}/results`, + * but is otherwise the same as [TestResultService.list]. + */ + @MustBeClosed + fun list(params: TestResultListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: TestResultListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt new file mode 100644 index 00000000..ca926f79 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.handlers.withErrorHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListResponse + +class TestResultServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultService { + + private val withRawResponse: TestResultService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TestResultService.WithRawResponse = withRawResponse + + override fun list( + params: TestResultListParams, + requestOptions: RequestOptions, + ): TestResultListResponse = + // get /inference-pipelines/{inferencePipelineId}/results + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TestResultService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun list( + params: TestResultListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("inference-pipelines", params._pathParam(0), "results") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt index 9874a6ee..1e897572 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt @@ -1,28 +1,72 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking.projects +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.ProjectCommitCreateParams -import com.openlayer.api.models.ProjectCommitCreateResponse -import com.openlayer.api.models.ProjectCommitListParams -import com.openlayer.api.models.ProjectCommitListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.projects.commits.CommitCreateParams +import com.openlayer.api.models.projects.commits.CommitCreateResponse +import com.openlayer.api.models.projects.commits.CommitListParams +import com.openlayer.api.models.projects.commits.CommitListResponse interface CommitService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Create a new commit (project version) in a project. */ - @JvmOverloads + fun create(params: CommitCreateParams): CommitCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( - params: ProjectCommitCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectCommitCreateResponse + params: CommitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitCreateResponse /** List the commits (project versions) in a project. */ - @JvmOverloads + fun list(params: CommitListParams): CommitListResponse = list(params, RequestOptions.none()) + + /** @see [list] */ fun list( - params: ProjectCommitListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectCommitListResponse + params: CommitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CommitListResponse + + /** A view of [CommitService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /projects/{projectId}/versions`, but is otherwise + * the same as [CommitService.create]. + */ + @MustBeClosed + fun create(params: CommitCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: CommitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /projects/{projectId}/versions`, but is otherwise + * the same as [CommitService.list]. + */ + @MustBeClosed + fun list(params: CommitListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: CommitListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt index 283067fd..1342de0e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,76 +11,95 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.ProjectCommitCreateParams -import com.openlayer.api.models.ProjectCommitCreateResponse -import com.openlayer.api.models.ProjectCommitListParams -import com.openlayer.api.models.ProjectCommitListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.projects.commits.CommitCreateParams +import com.openlayer.api.models.projects.commits.CommitCreateResponse +import com.openlayer.api.models.projects.commits.CommitListParams +import com.openlayer.api.models.projects.commits.CommitListResponse -class CommitServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : CommitService { +class CommitServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CommitService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: CommitService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): CommitService.WithRawResponse = withRawResponse - /** Create a new commit (project version) in a project. */ override fun create( - params: ProjectCommitCreateParams, - requestOptions: RequestOptions - ): ProjectCommitCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects", params.getPathParam(0), "versions") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: CommitCreateParams, + requestOptions: RequestOptions, + ): CommitCreateResponse = + // post /projects/{projectId}/versions + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: CommitListParams, + requestOptions: RequestOptions, + ): CommitListResponse = + // get /projects/{projectId}/versions + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CommitService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: CommitCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects", params._pathParam(0), "versions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - /** List the commits (project versions) in a project. */ - override fun list( - params: ProjectCommitListParams, - requestOptions: RequestOptions - ): ProjectCommitListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("projects", params.getPathParam(0), "versions") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: CommitListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects", params._pathParam(0), "versions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineService.kt index 93989fbb..e2654efa 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineService.kt @@ -1,28 +1,78 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking.projects +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.ProjectInferencePipelineCreateParams -import com.openlayer.api.models.ProjectInferencePipelineCreateResponse -import com.openlayer.api.models.ProjectInferencePipelineListParams -import com.openlayer.api.models.ProjectInferencePipelineListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateResponse +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListResponse interface InferencePipelineService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Create an inference pipeline in a project. */ - @JvmOverloads + fun create(params: InferencePipelineCreateParams): InferencePipelineCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( - params: ProjectInferencePipelineCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectInferencePipelineCreateResponse + params: InferencePipelineCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InferencePipelineCreateResponse /** List the inference pipelines in a project. */ - @JvmOverloads + fun list(params: InferencePipelineListParams): InferencePipelineListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ fun list( - params: ProjectInferencePipelineListParams, - requestOptions: RequestOptions = RequestOptions.none() - ): ProjectInferencePipelineListResponse + params: InferencePipelineListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InferencePipelineListResponse + + /** + * A view of [InferencePipelineService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /projects/{projectId}/inference-pipelines`, but is + * otherwise the same as [InferencePipelineService.create]. + */ + @MustBeClosed + fun create( + params: InferencePipelineCreateParams + ): HttpResponseFor = create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: InferencePipelineCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /projects/{projectId}/inference-pipelines`, but is + * otherwise the same as [InferencePipelineService.list]. + */ + @MustBeClosed + fun list( + params: InferencePipelineListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt index 22268409..194d911d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,76 +11,96 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.ProjectInferencePipelineCreateParams -import com.openlayer.api.models.ProjectInferencePipelineCreateResponse -import com.openlayer.api.models.ProjectInferencePipelineListParams -import com.openlayer.api.models.ProjectInferencePipelineListResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateResponse +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListResponse -class InferencePipelineServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : InferencePipelineService { +class InferencePipelineServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InferencePipelineService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: InferencePipelineService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): InferencePipelineService.WithRawResponse = withRawResponse - /** Create an inference pipeline in a project. */ override fun create( - params: ProjectInferencePipelineCreateParams, - requestOptions: RequestOptions - ): ProjectInferencePipelineCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects", params.getPathParam(0), "inference-pipelines") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: InferencePipelineCreateParams, + requestOptions: RequestOptions, + ): InferencePipelineCreateResponse = + // post /projects/{projectId}/inference-pipelines + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions, + ): InferencePipelineListResponse = + // get /projects/{projectId}/inference-pipelines + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InferencePipelineService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: InferencePipelineCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects", params._pathParam(0), "inference-pipelines") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } - } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) - /** List the inference pipelines in a project. */ - override fun list( - params: ProjectInferencePipelineListParams, - requestOptions: RequestOptions - ): ProjectInferencePipelineListResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .addPathSegments("projects", params.getPathParam(0), "inference-pipelines") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { listHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + override fun list( + params: InferencePipelineListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects", params._pathParam(0), "inference-pipelines") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlService.kt index 6cc179e5..01a7867b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlService.kt @@ -1,19 +1,48 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking.storage +import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.StoragePresignedUrlCreateParams -import com.openlayer.api.models.StoragePresignedUrlCreateResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateResponse interface PresignedUrlService { + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + /** Retrieve a presigned url to post storage artifacts. */ - @JvmOverloads + fun create(params: PresignedUrlCreateParams): PresignedUrlCreateResponse = + create(params, RequestOptions.none()) + + /** @see [create] */ fun create( - params: StoragePresignedUrlCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): StoragePresignedUrlCreateResponse + params: PresignedUrlCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PresignedUrlCreateResponse + + /** + * A view of [PresignedUrlService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a raw HTTP response for `post /storage/presigned-url`, but is otherwise the same + * as [PresignedUrlService.create]. + */ + @MustBeClosed + fun create(params: PresignedUrlCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + params: PresignedUrlCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt index e89676fa..76933320 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.storage import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -10,45 +11,60 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.StoragePresignedUrlCreateParams -import com.openlayer.api.models.StoragePresignedUrlCreateResponse +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateResponse -class PresignedUrlServiceImpl -constructor( - private val clientOptions: ClientOptions, -) : PresignedUrlService { +class PresignedUrlServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PresignedUrlService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val withRawResponse: PresignedUrlService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - .withErrorHandler(errorHandler) + override fun withRawResponse(): PresignedUrlService.WithRawResponse = withRawResponse - /** Retrieve a presigned url to post storage artifacts. */ override fun create( - params: StoragePresignedUrlCreateParams, - requestOptions: RequestOptions - ): StoragePresignedUrlCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("storage", "presigned-url") - .putAllQueryParams(clientOptions.queryParams) - .replaceAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .replaceAllHeaders(params.getHeaders()) - .apply { params.getBody().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() + params: PresignedUrlCreateParams, + requestOptions: RequestOptions, + ): PresignedUrlCreateResponse = + // post /storage/presigned-url + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PresignedUrlService.WithRawResponse { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + override fun create( + params: PresignedUrlCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("storage", "presigned-url") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return response.parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } } - } + } } } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/TestServerExtension.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/TestServerExtension.kt index 0d72bda9..b415aff6 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/TestServerExtension.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/TestServerExtension.kt @@ -36,7 +36,7 @@ class TestServerExtension : BeforeAllCallback, ExecutionCondition { $ prism mock path/to/your.openapi.yml """ .trimIndent(), - e + e, ) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/ObjectMappersTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/ObjectMappersTest.kt new file mode 100644 index 00000000..d1ae0df7 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/ObjectMappersTest.kt @@ -0,0 +1,102 @@ +package com.openlayer.api.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/PhantomReachableTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/PhantomReachableTest.kt index b991a43c..e57f8a41 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/PhantomReachableTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/PhantomReachableTest.kt @@ -14,7 +14,7 @@ internal class PhantomReachableTest { // Pass an inline object for the object to observe so that it becomes immediately // unreachable. Any(), - closeable + closeable, ) assertThat(closed).isFalse() diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/UtilsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/UtilsTest.kt new file mode 100644 index 00000000..18feeb5e --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package com.openlayer.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/ValuesTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/ValuesTest.kt new file mode 100644 index 00000000..3b63f05b --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package com.openlayer.api.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty(), + val expectedAsBoolean: Optional = Optional.empty(), + val expectedAsNumber: Optional = Optional.empty(), + val expectedAsString: Optional = Optional.empty(), + val expectedAsArray: Optional> = Optional.empty(), + val expectedAsObject: Optional> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/HeadersTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/HeadersTest.kt index 0780679e..c0127205 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/HeadersTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/HeadersTest.kt @@ -11,28 +11,28 @@ internal class HeadersTest { enum class TestCase( val headers: Headers, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( Headers.builder().put("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( Headers.builder().put("name1", "value").put("name2", "value").build(), expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( Headers.builder().put("name", "value1").put("name", "value2").build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( Headers.builder() @@ -40,7 +40,7 @@ internal class HeadersTest { .put("name", listOf("value1", "value2")) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_CASE_INSENSITIVE( Headers.builder() @@ -49,25 +49,25 @@ internal class HeadersTest { .put("nAmE", "value3") .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), PUT_ALL_MAP( Headers.builder() .putAll( mapOf( "name1" to listOf("value1", "value2"), - "name2" to listOf("value1", "value2") + "name2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_ALL_CASE_INSENSITIVE( Headers.builder() @@ -75,32 +75,32 @@ internal class HeadersTest { mapOf( "name" to listOf("value1"), "NAME" to listOf("value2"), - "nAmE" to listOf("value3") + "nAmE" to listOf("value3"), ) ) .build(), expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), - expectedSize = 3 + expectedSize = 3, ), REMOVE_ABSENT( Headers.builder().remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( Headers.builder().put("name", "value").remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_CASE_INSENSITIVE( Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( Headers.builder() @@ -109,7 +109,7 @@ internal class HeadersTest { .removeAll(setOf("name1", "name2", "name3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -118,22 +118,22 @@ internal class HeadersTest { .removeAll(setOf("NAME1", "nAmE3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( Headers.builder().put("name1", "value").put("name2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( Headers.builder().replace("name", "value").build(), expectedMap = mapOf("name" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( Headers.builder().put("name", "value1").replace("name", "value2").build(), expectedMap = mapOf("name" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( Headers.builder() @@ -141,12 +141,12 @@ internal class HeadersTest { .replace("name", "value3") .build(), expectedMap = mapOf("name" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( Headers.builder().replace("name", listOf("value1", "value2")).build(), expectedMap = mapOf("name" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( Headers.builder() @@ -154,7 +154,7 @@ internal class HeadersTest { .replace("name", listOf("value2", "value3")) .build(), expectedMap = mapOf("name" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( Headers.builder() @@ -162,7 +162,7 @@ internal class HeadersTest { .replace("name", listOf("value3", "value4")) .build(), expectedMap = mapOf("name" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_CASE_INSENSITIVE( Headers.builder() @@ -170,7 +170,7 @@ internal class HeadersTest { .replace("NAME", listOf("value2", "value3")) .build(), expectedMap = mapOf("NAME" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( Headers.builder() @@ -183,9 +183,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( Headers.builder() @@ -198,9 +198,9 @@ internal class HeadersTest { mapOf( "name1" to listOf("value2"), "name2" to listOf("value1"), - "name3" to listOf("value2") + "name3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_CASE_INSENSITIVE( Headers.builder() @@ -209,8 +209,8 @@ internal class HeadersTest { .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) .build(), expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), - expectedSize = 2 - ) + expectedSize = 2, + ), } @ParameterizedTest diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/QueryParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/QueryParamsTest.kt index 7db575e3..51000b8c 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/QueryParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/QueryParamsTest.kt @@ -11,28 +11,28 @@ internal class QueryParamsTest { enum class TestCase( val queryParams: QueryParams, val expectedMap: Map>, - val expectedSize: Int + val expectedSize: Int, ) { EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), PUT_ONE( QueryParams.builder().put("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), PUT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT( QueryParams.builder().put("key1", "value").put("key2", "value").build(), expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_SAME_NAME( QueryParams.builder().put("key", "value1").put("key", "value2").build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), MULTIPLE_PUT_MULTIPLE( QueryParams.builder() @@ -40,40 +40,40 @@ internal class QueryParamsTest { .put("key", listOf("value1", "value2")) .build(), expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_MAP( QueryParams.builder() .putAll( mapOf( "key1" to listOf("value1", "value2"), - "key2" to listOf("value1", "value2") + "key2" to listOf("value1", "value2"), ) ) .build(), expectedMap = mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), - expectedSize = 4 + expectedSize = 4, ), PUT_ALL_HEADERS( QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REMOVE_ABSENT( QueryParams.builder().remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_ONE( QueryParams.builder().put("key", "value").remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_PRESENT_MULTIPLE( QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REMOVE_ALL( QueryParams.builder() @@ -82,22 +82,22 @@ internal class QueryParamsTest { .removeAll(setOf("key1", "key2", "key3")) .build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), CLEAR( QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), expectedMap = mapOf(), - expectedSize = 0 + expectedSize = 0, ), REPLACE_ONE_ABSENT( QueryParams.builder().replace("key", "value").build(), expectedMap = mapOf("key" to listOf("value")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_ONE( QueryParams.builder().put("key", "value1").replace("key", "value2").build(), expectedMap = mapOf("key" to listOf("value2")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_ONE_PRESENT_MULTIPLE( QueryParams.builder() @@ -105,12 +105,12 @@ internal class QueryParamsTest { .replace("key", "value3") .build(), expectedMap = mapOf("key" to listOf("value3")), - expectedSize = 1 + expectedSize = 1, ), REPLACE_MULTIPLE_ABSENT( QueryParams.builder().replace("key", listOf("value1", "value2")).build(), expectedMap = mapOf("key" to listOf("value1", "value2")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_ONE( QueryParams.builder() @@ -118,7 +118,7 @@ internal class QueryParamsTest { .replace("key", listOf("value2", "value3")) .build(), expectedMap = mapOf("key" to listOf("value2", "value3")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_MULTIPLE_PRESENT_MULTIPLE( QueryParams.builder() @@ -126,7 +126,7 @@ internal class QueryParamsTest { .replace("key", listOf("value3", "value4")) .build(), expectedMap = mapOf("key" to listOf("value3", "value4")), - expectedSize = 2 + expectedSize = 2, ), REPLACE_ALL_MAP( QueryParams.builder() @@ -139,9 +139,9 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 + expectedSize = 3, ), REPLACE_ALL_HEADERS( QueryParams.builder() @@ -156,10 +156,10 @@ internal class QueryParamsTest { mapOf( "key1" to listOf("value2"), "key2" to listOf("value1"), - "key3" to listOf("value2") + "key3" to listOf("value2"), ), - expectedSize = 3 - ) + expectedSize = 3, + ), } @ParameterizedTest diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/RetryingHttpClientTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/RetryingHttpClientTest.kt index c6ccd9b7..8e89c85e 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/RetryingHttpClientTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/RetryingHttpClientTest.kt @@ -5,38 +5,83 @@ import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.github.tomakehurst.wiremock.stubbing.Scenario import com.openlayer.api.client.okhttp.OkHttpClient +import com.openlayer.api.core.RequestOptions +import java.io.InputStream +import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @WireMockTest internal class RetryingHttpClientTest { + private var openResponseCount = 0 private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + httpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } resetAllScenarios() } - @Test - fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } - @Test - fun whenProvidedShouldAddIdempotencyHeaderToRequest() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) @@ -45,21 +90,28 @@ internal class RetryingHttpClientTest { val retryingClient = RetryingHttpClient.builder() .httpClient(httpClient) + .maxRetries(2) .idempotencyHeader("X-Some-Header") .build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) + assertThat(response.statusCode()).isEqualTo(200) verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun retryAfterHeader(async: Boolean) { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + fun execute_withRetryAfterHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // first we fail with a retry after header given as a date + // First we fail with a retry after header given as a date + .inScenario("foo") .whenScenarioStateIs(Scenario.STARTED) .willReturn( serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") @@ -68,14 +120,16 @@ internal class RetryingHttpClientTest { ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we fail with a retry after header given as a delay + // Then we fail with a retry after header given as a delay + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DATE") .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) .willSetStateTo("RETRY_AFTER_DELAY") ) stubFor( post(urlPathEqualTo("/something")) - .inScenario("foo") // then we return a success + // Then we return a success + .inScenario("foo") .whenScenarioStateIs("RETRY_AFTER_DELAY") .willReturn(ok()) .willSetStateTo("COMPLETED") @@ -84,36 +138,33 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) assertThat(response.statusCode()).isEqualTo(200) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("0")) + .withHeader("x-stainless-retry-count", equalTo("0")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("1")) + .withHeader("x-stainless-retry-count", equalTo("1")), ) verify( 1, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("2")) + .withHeader("x-stainless-retry-count", equalTo("2")), ) + assertNoResponseLeaks() } @ParameterizedTest @ValueSource(booleans = [false, true]) - fun overwriteRetryCountHeader(async: Boolean) { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegment("something") - .putHeader("x-stainless-retry-count", "42") - .build() + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") // first we fail with a retry after header given as a date @@ -134,21 +185,27 @@ internal class RetryingHttpClientTest { RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() val response = - if (async) retryingClient.executeAsync(request).get() - else retryingClient.execute(request) + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async, + ) assertThat(response.statusCode()).isEqualTo(200) verify( 2, postRequestedFor(urlPathEqualTo("/something")) - .withHeader("x-stainless-retry-count", equalTo("42")) + .withHeader("x-stainless-retry-count", equalTo("42")), ) + assertNoResponseLeaks() } - @Test - fun retryAfterMsHeader() { - val request = - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { stubFor( post(urlPathEqualTo("/something")) .inScenario("foo") @@ -165,8 +222,22 @@ internal class RetryingHttpClientTest { ) val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() - val response = retryingClient.execute(request) + + val response = + retryingClient.execute( + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + async, + ) + assertThat(response.statusCode()).isEqualTo(200) verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() } + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/SerializerTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/SerializerTest.kt deleted file mode 100644 index 1acef186..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/core/http/SerializerTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -package com.openlayer.api.core.http - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.openlayer.api.core.* -import java.util.* -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SerializerTest { - @JsonDeserialize(builder = ClassWithBooleanFieldPrefixedWithIs.Builder::class) - @NoAutoDetect - class ClassWithBooleanFieldPrefixedWithIs - private constructor( - private val isActive: JsonField, - private val additionalProperties: Map, - ) { - private var validated: Boolean = false - - private var hashCode: Int = 0 - - fun isActive(): Boolean? = isActive.getNullable("is_active") - - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun validate() = apply { - if (!validated) { - isActive() - validated = true - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ClassWithBooleanFieldPrefixedWithIs && - isActive == other.isActive && - additionalProperties == other.additionalProperties - } - - override fun hashCode(): Int { - if (hashCode == 0) { - hashCode = - Objects.hash( - isActive, - additionalProperties, - ) - } - return hashCode - } - - override fun toString() = - "MyClass{isActive=$isActive, additionalProperties=$additionalProperties}" - - companion object { - fun builder() = Builder() - } - - @NoAutoDetect - class Builder { - private var isActive: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) - - @JsonProperty("is_active") - @ExcludeMissing - fun isActive(isActive: JsonField) = apply { this.isActive = isActive } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - this.additionalProperties.putAll(additionalProperties) - } - - @JsonAnySetter - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun build(): ClassWithBooleanFieldPrefixedWithIs = - ClassWithBooleanFieldPrefixedWithIs( - isActive, - additionalProperties.toImmutable(), - ) - } - } - - @Test - fun serializeBooleanPrefixedWithIs() { - val value = ClassWithBooleanFieldPrefixedWithIs.builder().isActive(true).build() - assertThat(jsonMapper().writeValueAsString(value)).isEqualTo("{\"is_active\":true}") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitTestResultListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitTestResultListParamsTest.kt deleted file mode 100644 index 2982dc94..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitTestResultListParamsTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CommitTestResultListParamsTest { - - @Test - fun createCommitTestResultListParams() { - CommitTestResultListParams.builder() - .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .includeArchived(true) - .page(1L) - .perPage(1L) - .status(CommitTestResultListParams.Status.RUNNING) - .type(CommitTestResultListParams.Type.INTEGRITY) - .build() - } - - @Test - fun getQueryParams() { - val params = - CommitTestResultListParams.builder() - .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .includeArchived(true) - .page(1L) - .perPage(1L) - .status(CommitTestResultListParams.Status.RUNNING) - .type(CommitTestResultListParams.Type.INTEGRITY) - .build() - val expected = QueryParams.builder() - expected.put("includeArchived", "true") - expected.put("page", "1") - expected.put("perPage", "1") - expected.put("status", CommitTestResultListParams.Status.RUNNING.toString()) - expected.put("type", CommitTestResultListParams.Type.INTEGRITY.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = - CommitTestResultListParams.builder() - .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getPathParam() { - val params = - CommitTestResultListParams.builder() - .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectVersionId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitTestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitTestResultListResponseTest.kt deleted file mode 100644 index dd83444a..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitTestResultListResponseTest.kt +++ /dev/null @@ -1,142 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class CommitTestResultListResponseTest { - - @Test - fun createCommitTestResultListResponse() { - val commitTestResultListResponse = - CommitTestResultListResponse.builder() - .items( - listOf( - CommitTestResultListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(CommitTestResultListResponse.Item.Status.RUNNING) - .statusMessage("Test successfully processed.") - .goal( - CommitTestResultListResponse.Item.Goal.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commentCount(0L) - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description( - JsonValue.from( - "This test checks for duplicate rows in the dataset." - ) - ) - .name("No duplicate rows") - .number(1L) - .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .subtype("duplicateRowCount") - .suggested(false) - .thresholds( - listOf( - CommitTestResultListResponse.Item.Goal.Threshold - .builder() - .insightName("duplicateRowCount") - .insightParameters( - listOf(JsonValue.from(mapOf())) - ) - .measurement("duplicateRowCount") - .operator("<=") - .value( - CommitTestResultListResponse.Item.Goal.Threshold - .Value - .ofNumber(0.0) - ) - .build() - ) - ) - .type("integrity") - .archived(false) - .delayWindow(0.0) - .evaluationWindow(3600.0) - .usesMlModel(false) - .usesProductionData(false) - .usesReferenceDataset(false) - .usesTrainingDataset(false) - .usesValidationDataset(true) - .build() - ) - .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - ) - .build() - assertThat(commitTestResultListResponse).isNotNull - assertThat(commitTestResultListResponse.items()) - .containsExactly( - CommitTestResultListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(CommitTestResultListResponse.Item.Status.RUNNING) - .statusMessage("Test successfully processed.") - .goal( - CommitTestResultListResponse.Item.Goal.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commentCount(0L) - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description( - JsonValue.from( - "This test checks for duplicate rows in the dataset." - ) - ) - .name("No duplicate rows") - .number(1L) - .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .subtype("duplicateRowCount") - .suggested(false) - .thresholds( - listOf( - CommitTestResultListResponse.Item.Goal.Threshold.builder() - .insightName("duplicateRowCount") - .insightParameters( - listOf(JsonValue.from(mapOf())) - ) - .measurement("duplicateRowCount") - .operator("<=") - .value( - CommitTestResultListResponse.Item.Goal.Threshold.Value - .ofNumber(0.0) - ) - .build() - ) - ) - .type("integrity") - .archived(false) - .delayWindow(0.0) - .evaluationWindow(3600.0) - .usesMlModel(false) - .usesProductionData(false) - .usesReferenceDataset(false) - .usesTrainingDataset(false) - .usesValidationDataset(true) - .build() - ) - .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDataStreamParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDataStreamParamsTest.kt deleted file mode 100644 index 3c97a0d4..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDataStreamParamsTest.kt +++ /dev/null @@ -1,217 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InferencePipelineDataStreamParamsTest { - - @Test - fun createInferencePipelineDataStreamParams() { - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt.builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - } - - @Test - fun getBody() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.config()) - .isEqualTo( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt.builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - assertThat(body.rows()) - .isEqualTo( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.config()) - .isEqualTo( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .build() - ) - ) - assertThat(body.rows()) - .isEqualTo( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - } - - @Test - fun getPathParam() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - assertThat(params).isNotNull - // path param "inferencePipelineId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDataStreamResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDataStreamResponseTest.kt deleted file mode 100644 index 5d5c07fc..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDataStreamResponseTest.kt +++ /dev/null @@ -1,20 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InferencePipelineDataStreamResponseTest { - - @Test - fun createInferencePipelineDataStreamResponse() { - val inferencePipelineDataStreamResponse = - InferencePipelineDataStreamResponse.builder() - .success(InferencePipelineDataStreamResponse.Success.TRUE) - .build() - assertThat(inferencePipelineDataStreamResponse).isNotNull - assertThat(inferencePipelineDataStreamResponse.success()) - .isEqualTo(InferencePipelineDataStreamResponse.Success.TRUE) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateResponseTest.kt deleted file mode 100644 index 427675b7..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateResponseTest.kt +++ /dev/null @@ -1,20 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InferencePipelineRowUpdateResponseTest { - - @Test - fun createInferencePipelineRowUpdateResponse() { - val inferencePipelineRowUpdateResponse = - InferencePipelineRowUpdateResponse.builder() - .success(InferencePipelineRowUpdateResponse.Success.TRUE) - .build() - assertThat(inferencePipelineRowUpdateResponse).isNotNull - assertThat(inferencePipelineRowUpdateResponse.success()) - .isEqualTo(InferencePipelineRowUpdateResponse.Success.TRUE) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineTestResultListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineTestResultListParamsTest.kt deleted file mode 100644 index b15691d9..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineTestResultListParamsTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InferencePipelineTestResultListParamsTest { - - @Test - fun createInferencePipelineTestResultListParams() { - InferencePipelineTestResultListParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .page(1L) - .perPage(1L) - .status(InferencePipelineTestResultListParams.Status.RUNNING) - .type(InferencePipelineTestResultListParams.Type.INTEGRITY) - .build() - } - - @Test - fun getQueryParams() { - val params = - InferencePipelineTestResultListParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .page(1L) - .perPage(1L) - .status(InferencePipelineTestResultListParams.Status.RUNNING) - .type(InferencePipelineTestResultListParams.Type.INTEGRITY) - .build() - val expected = QueryParams.builder() - expected.put("page", "1") - expected.put("perPage", "1") - expected.put("status", InferencePipelineTestResultListParams.Status.RUNNING.toString()) - expected.put("type", InferencePipelineTestResultListParams.Type.INTEGRITY.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = - InferencePipelineTestResultListParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getPathParam() { - val params = - InferencePipelineTestResultListParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "inferencePipelineId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineTestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineTestResultListResponseTest.kt deleted file mode 100644 index fb5a0e01..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineTestResultListResponseTest.kt +++ /dev/null @@ -1,148 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.JsonValue -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class InferencePipelineTestResultListResponseTest { - - @Test - fun createInferencePipelineTestResultListResponse() { - val inferencePipelineTestResultListResponse = - InferencePipelineTestResultListResponse.builder() - .items( - listOf( - InferencePipelineTestResultListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(InferencePipelineTestResultListResponse.Item.Status.RUNNING) - .statusMessage("Test successfully processed.") - .goal( - InferencePipelineTestResultListResponse.Item.Goal.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commentCount(0L) - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description( - JsonValue.from( - "This test checks for duplicate rows in the dataset." - ) - ) - .name("No duplicate rows") - .number(1L) - .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .subtype("duplicateRowCount") - .suggested(false) - .thresholds( - listOf( - InferencePipelineTestResultListResponse.Item.Goal - .Threshold - .builder() - .insightName("duplicateRowCount") - .insightParameters( - listOf(JsonValue.from(mapOf())) - ) - .measurement("duplicateRowCount") - .operator("<=") - .value( - InferencePipelineTestResultListResponse.Item - .Goal - .Threshold - .Value - .ofNumber(0.0) - ) - .build() - ) - ) - .type("integrity") - .archived(false) - .delayWindow(0.0) - .evaluationWindow(3600.0) - .usesMlModel(false) - .usesProductionData(false) - .usesReferenceDataset(false) - .usesTrainingDataset(false) - .usesValidationDataset(true) - .build() - ) - .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - ) - .build() - assertThat(inferencePipelineTestResultListResponse).isNotNull - assertThat(inferencePipelineTestResultListResponse.items()) - .containsExactly( - InferencePipelineTestResultListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(InferencePipelineTestResultListResponse.Item.Status.RUNNING) - .statusMessage("Test successfully processed.") - .goal( - InferencePipelineTestResultListResponse.Item.Goal.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commentCount(0L) - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description( - JsonValue.from( - "This test checks for duplicate rows in the dataset." - ) - ) - .name("No duplicate rows") - .number(1L) - .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .subtype("duplicateRowCount") - .suggested(false) - .thresholds( - listOf( - InferencePipelineTestResultListResponse.Item.Goal.Threshold - .builder() - .insightName("duplicateRowCount") - .insightParameters( - listOf(JsonValue.from(mapOf())) - ) - .measurement("duplicateRowCount") - .operator("<=") - .value( - InferencePipelineTestResultListResponse.Item.Goal - .Threshold - .Value - .ofNumber(0.0) - ) - .build() - ) - ) - .type("integrity") - .archived(false) - .delayWindow(0.0) - .evaluationWindow(3600.0) - .usesMlModel(false) - .usesProductionData(false) - .usesReferenceDataset(false) - .usesTrainingDataset(false) - .usesValidationDataset(true) - .build() - ) - .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt deleted file mode 100644 index 40af250c..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt +++ /dev/null @@ -1,148 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectCommitCreateParamsTest { - - @Test - fun createProjectCommitCreateParams() { - ProjectCommitCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit( - ProjectCommitCreateParams.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - .storageUri("s3://...") - .archived(false) - .deploymentStatus("Deployed") - .build() - } - - @Test - fun getBody() { - val params = - ProjectCommitCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit( - ProjectCommitCreateParams.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - .storageUri("s3://...") - .archived(false) - .deploymentStatus("Deployed") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.commit()) - .isEqualTo( - ProjectCommitCreateParams.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - assertThat(body.storageUri()).isEqualTo("s3://...") - assertThat(body.archived()).isEqualTo(false) - assertThat(body.deploymentStatus()).isEqualTo("Deployed") - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = - ProjectCommitCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit( - ProjectCommitCreateParams.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - .storageUri("s3://...") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.commit()) - .isEqualTo( - ProjectCommitCreateParams.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - assertThat(body.storageUri()).isEqualTo("s3://...") - } - - @Test - fun getPathParam() { - val params = - ProjectCommitCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .commit( - ProjectCommitCreateParams.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .build() - ) - .storageUri("s3://...") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt deleted file mode 100644 index 9720a0e6..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectCommitCreateResponseTest { - - @Test - fun createProjectCommitCreateResponse() { - val projectCommitCreateResponse = - ProjectCommitCreateResponse.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commit( - ProjectCommitCreateResponse.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .failingGoalCount(1L) - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .passingGoalCount(5L) - .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(ProjectCommitCreateResponse.Status.QUEUED) - .statusMessage("Commit successfully processed.") - .storageUri("s3://...") - .totalGoalCount(6L) - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .archived(false) - .deploymentStatus("Deployed") - .links( - ProjectCommitCreateResponse.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .build() - assertThat(projectCommitCreateResponse).isNotNull - assertThat(projectCommitCreateResponse.id()) - .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectCommitCreateResponse.commit()) - .isEqualTo( - ProjectCommitCreateResponse.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - assertThat(projectCommitCreateResponse.dateArchived()) - .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectCommitCreateResponse.dateCreated()) - .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectCommitCreateResponse.failingGoalCount()).isEqualTo(1L) - assertThat(projectCommitCreateResponse.mlModelId()) - .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectCommitCreateResponse.passingGoalCount()).isEqualTo(5L) - assertThat(projectCommitCreateResponse.projectId()) - .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectCommitCreateResponse.status()) - .isEqualTo(ProjectCommitCreateResponse.Status.QUEUED) - assertThat(projectCommitCreateResponse.statusMessage()) - .contains("Commit successfully processed.") - assertThat(projectCommitCreateResponse.storageUri()).isEqualTo("s3://...") - assertThat(projectCommitCreateResponse.totalGoalCount()).isEqualTo(6L) - assertThat(projectCommitCreateResponse.trainingDatasetId()) - .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectCommitCreateResponse.validationDatasetId()) - .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectCommitCreateResponse.archived()).contains(false) - assertThat(projectCommitCreateResponse.deploymentStatus()).contains("Deployed") - assertThat(projectCommitCreateResponse.links()) - .contains( - ProjectCommitCreateResponse.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitListParamsTest.kt deleted file mode 100644 index 563b800b..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitListParamsTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectCommitListParamsTest { - - @Test - fun createProjectCommitListParams() { - ProjectCommitListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .page(1L) - .perPage(1L) - .build() - } - - @Test - fun getQueryParams() { - val params = - ProjectCommitListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .page(1L) - .perPage(1L) - .build() - val expected = QueryParams.builder() - expected.put("page", "1") - expected.put("perPage", "1") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = - ProjectCommitListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getPathParam() { - val params = - ProjectCommitListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitListResponseTest.kt deleted file mode 100644 index a7aff626..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitListResponseTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectCommitListResponseTest { - - @Test - fun createProjectCommitListResponse() { - val projectCommitListResponse = - ProjectCommitListResponse.builder() - .items( - listOf( - ProjectCommitListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commit( - ProjectCommitListResponse.Item.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .failingGoalCount(1L) - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .passingGoalCount(5L) - .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(ProjectCommitListResponse.Item.Status.QUEUED) - .statusMessage("Commit successfully processed.") - .storageUri("s3://...") - .totalGoalCount(6L) - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .archived(false) - .deploymentStatus("Deployed") - .links( - ProjectCommitListResponse.Item.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .build() - ) - ) - .build() - assertThat(projectCommitListResponse).isNotNull - assertThat(projectCommitListResponse.items()) - .containsExactly( - ProjectCommitListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .commit( - ProjectCommitListResponse.Item.Commit.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .fileSize(1024L) - .message("Updated the prompt.") - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .storageUri("s3://...") - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .gitCommitRef("main") - .gitCommitSha(0L) - .gitCommitUrl("gitCommitUrl") - .build() - ) - .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .failingGoalCount(1L) - .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .passingGoalCount(5L) - .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(ProjectCommitListResponse.Item.Status.QUEUED) - .statusMessage("Commit successfully processed.") - .storageUri("s3://...") - .totalGoalCount(6L) - .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .archived(false) - .deploymentStatus("Deployed") - .links( - ProjectCommitListResponse.Item.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .build() - ) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateParamsTest.kt deleted file mode 100644 index 2d6f944e..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateParamsTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectCreateParamsTest { - - @Test - fun createProjectCreateParams() { - ProjectCreateParams.builder() - .name("My Project") - .taskType(ProjectCreateParams.TaskType.LLM_BASE) - .description("My project description.") - .build() - } - - @Test - fun getBody() { - val params = - ProjectCreateParams.builder() - .name("My Project") - .taskType(ProjectCreateParams.TaskType.LLM_BASE) - .description("My project description.") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("My Project") - assertThat(body.taskType()).isEqualTo(ProjectCreateParams.TaskType.LLM_BASE) - assertThat(body.description()).isEqualTo("My project description.") - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = - ProjectCreateParams.builder() - .name("My Project") - .taskType(ProjectCreateParams.TaskType.LLM_BASE) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("My Project") - assertThat(body.taskType()).isEqualTo(ProjectCreateParams.TaskType.LLM_BASE) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateParamsTest.kt deleted file mode 100644 index fac797b0..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateParamsTest.kt +++ /dev/null @@ -1,270 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.LocalDate -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectInferencePipelineCreateParamsTest { - - @Test - fun createProjectInferencePipelineCreateParams() { - ProjectInferencePipelineCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("This pipeline is used for production.") - .name("production") - .project( - ProjectInferencePipelineCreateParams.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineCreateParams.Project.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectInferencePipelineCreateParams.Project.Source.WEB) - .taskType(ProjectInferencePipelineCreateParams.Project.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineCreateParams.Project.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - .workspace( - ProjectInferencePipelineCreateParams.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .projectCount(0L) - .slug("openlayer") - .status(ProjectInferencePipelineCreateParams.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineCreateParams.Workspace.MonthlyUsage.builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - .build() - } - - @Test - fun getBody() { - val params = - ProjectInferencePipelineCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("This pipeline is used for production.") - .name("production") - .project( - ProjectInferencePipelineCreateParams.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineCreateParams.Project.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectInferencePipelineCreateParams.Project.Source.WEB) - .taskType(ProjectInferencePipelineCreateParams.Project.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineCreateParams.Project.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - .workspace( - ProjectInferencePipelineCreateParams.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .projectCount(0L) - .slug("openlayer") - .status(ProjectInferencePipelineCreateParams.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineCreateParams.Workspace.MonthlyUsage - .builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("This pipeline is used for production.") - assertThat(body.name()).isEqualTo("production") - assertThat(body.project()) - .isEqualTo( - ProjectInferencePipelineCreateParams.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineCreateParams.Project.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectInferencePipelineCreateParams.Project.Source.WEB) - .taskType(ProjectInferencePipelineCreateParams.Project.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineCreateParams.Project.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - assertThat(body.workspace()) - .isEqualTo( - ProjectInferencePipelineCreateParams.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .projectCount(0L) - .slug("openlayer") - .status(ProjectInferencePipelineCreateParams.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineCreateParams.Workspace.MonthlyUsage.builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - } - - @Test - fun getBodyWithoutOptionalFields() { - val params = - ProjectInferencePipelineCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("production") - .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.name()).isEqualTo("production") - } - - @Test - fun getPathParam() { - val params = - ProjectInferencePipelineCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("production") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateResponseTest.kt deleted file mode 100644 index 646bc7ec..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineCreateResponseTest.kt +++ /dev/null @@ -1,216 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.LocalDate -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectInferencePipelineCreateResponseTest { - - @Test - fun createProjectInferencePipelineCreateResponse() { - val projectInferencePipelineCreateResponse = - ProjectInferencePipelineCreateResponse.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description("This pipeline is used for production.") - .failingGoalCount(1L) - .links( - ProjectInferencePipelineCreateResponse.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .name("production") - .passingGoalCount(5L) - .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(ProjectInferencePipelineCreateResponse.Status.QUEUED) - .statusMessage("Tests successfully evaluated") - .totalGoalCount(6L) - .project( - ProjectInferencePipelineCreateResponse.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineCreateResponse.Project.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectInferencePipelineCreateResponse.Project.Source.WEB) - .taskType(ProjectInferencePipelineCreateResponse.Project.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineCreateResponse.Project.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - .workspace( - ProjectInferencePipelineCreateResponse.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .projectCount(0L) - .slug("openlayer") - .status(ProjectInferencePipelineCreateResponse.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineCreateResponse.Workspace.MonthlyUsage - .builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .build() - assertThat(projectInferencePipelineCreateResponse).isNotNull - assertThat(projectInferencePipelineCreateResponse.id()) - .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectInferencePipelineCreateResponse.dateCreated()) - .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectInferencePipelineCreateResponse.dateLastEvaluated()) - .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectInferencePipelineCreateResponse.dateLastSampleReceived()) - .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectInferencePipelineCreateResponse.dateOfNextEvaluation()) - .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectInferencePipelineCreateResponse.dateUpdated()) - .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - assertThat(projectInferencePipelineCreateResponse.description()) - .contains("This pipeline is used for production.") - assertThat(projectInferencePipelineCreateResponse.failingGoalCount()).isEqualTo(1L) - assertThat(projectInferencePipelineCreateResponse.links()) - .isEqualTo( - ProjectInferencePipelineCreateResponse.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - assertThat(projectInferencePipelineCreateResponse.name()).isEqualTo("production") - assertThat(projectInferencePipelineCreateResponse.passingGoalCount()).isEqualTo(5L) - assertThat(projectInferencePipelineCreateResponse.projectId()) - .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(projectInferencePipelineCreateResponse.status()) - .isEqualTo(ProjectInferencePipelineCreateResponse.Status.QUEUED) - assertThat(projectInferencePipelineCreateResponse.statusMessage()) - .contains("Tests successfully evaluated") - assertThat(projectInferencePipelineCreateResponse.totalGoalCount()).isEqualTo(6L) - assertThat(projectInferencePipelineCreateResponse.project()) - .contains( - ProjectInferencePipelineCreateResponse.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineCreateResponse.Project.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectInferencePipelineCreateResponse.Project.Source.WEB) - .taskType(ProjectInferencePipelineCreateResponse.Project.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineCreateResponse.Project.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - assertThat(projectInferencePipelineCreateResponse.workspace()) - .contains( - ProjectInferencePipelineCreateResponse.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .projectCount(0L) - .slug("openlayer") - .status(ProjectInferencePipelineCreateResponse.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineCreateResponse.Workspace.MonthlyUsage.builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - assertThat(projectInferencePipelineCreateResponse.workspaceId()) - .contains("055fddb1-261f-4654-8598-f6347ee46a09") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineListParamsTest.kt deleted file mode 100644 index 951afbc1..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineListParamsTest.kt +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectInferencePipelineListParamsTest { - - @Test - fun createProjectInferencePipelineListParams() { - ProjectInferencePipelineListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .page(1L) - .perPage(1L) - .build() - } - - @Test - fun getQueryParams() { - val params = - ProjectInferencePipelineListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .page(1L) - .perPage(1L) - .build() - val expected = QueryParams.builder() - expected.put("name", "name") - expected.put("page", "1") - expected.put("perPage", "1") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = - ProjectInferencePipelineListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getPathParam() { - val params = - ProjectInferencePipelineListParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - assertThat(params).isNotNull - // path param "projectId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineListResponseTest.kt deleted file mode 100644 index ec8ea795..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectInferencePipelineListResponseTest.kt +++ /dev/null @@ -1,237 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.LocalDate -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectInferencePipelineListResponseTest { - - @Test - fun createProjectInferencePipelineListResponse() { - val projectInferencePipelineListResponse = - ProjectInferencePipelineListResponse.builder() - .items( - listOf( - ProjectInferencePipelineListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateLastSampleReceived( - OffsetDateTime.parse("2024-03-22T11:31:01.185Z") - ) - .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description("This pipeline is used for production.") - .failingGoalCount(1L) - .links( - ProjectInferencePipelineListResponse.Item.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .name("production") - .passingGoalCount(5L) - .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(ProjectInferencePipelineListResponse.Item.Status.QUEUED) - .statusMessage("Tests successfully evaluated") - .totalGoalCount(6L) - .project( - ProjectInferencePipelineListResponse.Item.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineListResponse.Item.Project.Links - .builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source( - ProjectInferencePipelineListResponse.Item.Project.Source.WEB - ) - .taskType( - ProjectInferencePipelineListResponse.Item.Project.TaskType - .LLM_BASE - ) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineListResponse.Item.Project.GitRepo - .builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .dateUpdated( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - .workspace( - ProjectInferencePipelineListResponse.Item.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate( - OffsetDateTime.parse("2019-12-27T18:11:19.117Z") - ) - .projectCount(0L) - .slug("openlayer") - .status( - ProjectInferencePipelineListResponse.Item.Workspace.Status - .ACTIVE - ) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineListResponse.Item.Workspace - .MonthlyUsage - .builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .build() - ) - ) - .build() - assertThat(projectInferencePipelineListResponse).isNotNull - assertThat(projectInferencePipelineListResponse.items()) - .containsExactly( - ProjectInferencePipelineListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .description("This pipeline is used for production.") - .failingGoalCount(1L) - .links( - ProjectInferencePipelineListResponse.Item.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .name("production") - .passingGoalCount(5L) - .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(ProjectInferencePipelineListResponse.Item.Status.QUEUED) - .statusMessage("Tests successfully evaluated") - .totalGoalCount(6L) - .project( - ProjectInferencePipelineListResponse.Item.Project.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectInferencePipelineListResponse.Item.Project.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectInferencePipelineListResponse.Item.Project.Source.WEB) - .taskType( - ProjectInferencePipelineListResponse.Item.Project.TaskType.LLM_BASE - ) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectInferencePipelineListResponse.Item.Project.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - .workspace( - ProjectInferencePipelineListResponse.Item.Workspace.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .inviteCount(0L) - .memberCount(0L) - .name("Openlayer") - .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .projectCount(0L) - .slug("openlayer") - .status( - ProjectInferencePipelineListResponse.Item.Workspace.Status.ACTIVE - ) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineListResponse.Item.Workspace.MonthlyUsage - .builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() - ) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .build() - ) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectListResponseTest.kt deleted file mode 100644 index 26ef957e..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectListResponseTest.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class ProjectListResponseTest { - - @Test - fun createProjectListResponse() { - val projectListResponse = - ProjectListResponse.builder() - .items( - listOf( - ProjectListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectListResponse.Item.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectListResponse.Item.Source.WEB) - .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectListResponse.Item.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - ) - .build() - assertThat(projectListResponse).isNotNull - assertThat(projectListResponse.items()) - .containsExactly( - ProjectListResponse.Item.builder() - .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") - .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) - .developmentGoalCount(5L) - .goalCount(10L) - .inferencePipelineCount(1L) - .links( - ProjectListResponse.Item.Links.builder() - .app( - "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" - ) - .build() - ) - .monitoringGoalCount(5L) - .name("My Project") - .source(ProjectListResponse.Item.Source.WEB) - .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) - .versionCount(2L) - .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") - .description("My project description.") - .gitRepo( - ProjectListResponse.Item.GitRepo.builder() - .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .gitId(0L) - .name("name") - .private_(true) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .slug("slug") - .url("url") - .branch("branch") - .rootDir("rootDir") - .build() - ) - .build() - ) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateParamsTest.kt deleted file mode 100644 index d62003ac..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateParamsTest.kt +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class StoragePresignedUrlCreateParamsTest { - - @Test - fun createStoragePresignedUrlCreateParams() { - StoragePresignedUrlCreateParams.builder().objectName("objectName").build() - } - - @Test - fun getQueryParams() { - val params = StoragePresignedUrlCreateParams.builder().objectName("objectName").build() - val expected = QueryParams.builder() - expected.put("objectName", "objectName") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } - - @Test - fun getQueryParamsWithoutOptionalFields() { - val params = StoragePresignedUrlCreateParams.builder().objectName("objectName").build() - val expected = QueryParams.builder() - expected.put("objectName", "objectName") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateResponseTest.kt deleted file mode 100644 index c6dd2f5f..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/StoragePresignedUrlCreateResponseTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.models - -import com.openlayer.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class StoragePresignedUrlCreateResponseTest { - - @Test - fun createStoragePresignedUrlCreateResponse() { - val storagePresignedUrlCreateResponse = - StoragePresignedUrlCreateResponse.builder() - .storageUri("storageUri") - .url("url") - .fields(JsonValue.from(mapOf())) - .build() - assertThat(storagePresignedUrlCreateResponse).isNotNull - assertThat(storagePresignedUrlCreateResponse.storageUri()).isEqualTo("storageUri") - assertThat(storagePresignedUrlCreateResponse.url()).isEqualTo("url") - assertThat(storagePresignedUrlCreateResponse._fields()) - .isEqualTo(JsonValue.from(mapOf())) - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveParamsTest.kt new file mode 100644 index 00000000..cd6dbebb --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitRetrieveParamsTest { + + @Test + fun create() { + CommitRetrieveParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + CommitRetrieveParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt new file mode 100644 index 00000000..1183d6fe --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitRetrieveResponseTest { + + @Test + fun create() { + val commitRetrieveResponse = + CommitRetrieveResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitRetrieveResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitRetrieveResponse.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitRetrieveResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + assertThat(commitRetrieveResponse.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitRetrieveResponse.commit()) + .isEqualTo( + CommitRetrieveResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + assertThat(commitRetrieveResponse.dateArchived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(commitRetrieveResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(commitRetrieveResponse.failingGoalCount()).isEqualTo(1L) + assertThat(commitRetrieveResponse.mlModelId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitRetrieveResponse.passingGoalCount()).isEqualTo(5L) + assertThat(commitRetrieveResponse.projectId()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitRetrieveResponse.status()) + .isEqualTo(CommitRetrieveResponse.Status.COMPLETED) + assertThat(commitRetrieveResponse.statusMessage()) + .contains("Commit successfully processed.") + assertThat(commitRetrieveResponse.totalGoalCount()).isEqualTo(6L) + assertThat(commitRetrieveResponse.trainingDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitRetrieveResponse.validationDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitRetrieveResponse.archived()).contains(false) + assertThat(commitRetrieveResponse.deploymentStatus()).contains("Deployed") + assertThat(commitRetrieveResponse.links()) + .contains( + CommitRetrieveResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitRetrieveResponse = + CommitRetrieveResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitRetrieveResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitRetrieveResponse.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitRetrieveResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + val roundtrippedCommitRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommitRetrieveResponse).isEqualTo(commitRetrieveResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParamsTest.kt new file mode 100644 index 00000000..4d27d136 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits.testresults + +import com.openlayer.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TestResultListParamsTest { + + @Test + fun create() { + TestResultListParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(1L) + .perPage(1L) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) + .build() + } + + @Test + fun pathParams() { + val params = + TestResultListParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + TestResultListParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(1L) + .perPage(1L) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("includeArchived", "true") + .put("page", "1") + .put("perPage", "1") + .put("status", "passing") + .put("type", "integrity") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + TestResultListParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt new file mode 100644 index 00000000..93ea3add --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.commits.testresults + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TestResultListResponseTest { + + @Test + fun create() { + val testResultListResponse = + TestResultListResponse.builder() + .addItem( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.PASSING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .build() + + assertThat(testResultListResponse.items()) + .containsExactly( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.PASSING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val testResultListResponse = + TestResultListResponse.builder() + .addItem( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.PASSING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .build() + + val roundtrippedTestResultListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(testResultListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTestResultListResponse).isEqualTo(testResultListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDeleteParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineDeleteParamsTest.kt similarity index 58% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDeleteParamsTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineDeleteParamsTest.kt index 7e24f8ed..4b7f2a2f 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineDeleteParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineDeleteParamsTest.kt @@ -1,29 +1,28 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InferencePipelineDeleteParamsTest { +internal class InferencePipelineDeleteParamsTest { @Test - fun createInferencePipelineDeleteParams() { + fun create() { InferencePipelineDeleteParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @Test - fun getPathParam() { + fun pathParams() { val params = InferencePipelineDeleteParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - assertThat(params).isNotNull - // path param "inferencePipelineId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + assertThat(params._pathParam(1)).isEqualTo("") } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRetrieveParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParamsTest.kt similarity index 50% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRetrieveParamsTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParamsTest.kt index cb3cfc65..65d06ecb 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRetrieveParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParamsTest.kt @@ -1,53 +1,58 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines import com.openlayer.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InferencePipelineRetrieveParamsTest { +internal class InferencePipelineRetrieveParamsTest { @Test - fun createInferencePipelineRetrieveParams() { + fun create() { InferencePipelineRetrieveParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expand(listOf(InferencePipelineRetrieveParams.Expand.PROJECT)) + .addExpand(InferencePipelineRetrieveParams.Expand.PROJECT) .build() } @Test - fun getQueryParams() { + fun pathParams() { val params = InferencePipelineRetrieveParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expand(listOf(InferencePipelineRetrieveParams.Expand.PROJECT)) .build() - val expected = QueryParams.builder() - expected.put("expand", InferencePipelineRetrieveParams.Expand.PROJECT.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParams() { val params = InferencePipelineRetrieveParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExpand(InferencePipelineRetrieveParams.Expand.PROJECT) .build() - val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("expand", listOf("project").joinToString(",")).build() + ) } @Test - fun getPathParam() { + fun queryParamsWithoutOptionalFields() { val params = InferencePipelineRetrieveParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - assertThat(params).isNotNull - // path param "inferencePipelineId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRetrieveResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt similarity index 62% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRetrieveResponseTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt index 9b516de7..38456bee 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRetrieveResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt @@ -1,16 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.LocalDate import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InferencePipelineRetrieveResponseTest { +internal class InferencePipelineRetrieveResponseTest { @Test - fun createInferencePipelineRetrieveResponse() { + fun create() { val inferencePipelineRetrieveResponse = InferencePipelineRetrieveResponse.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") @@ -31,7 +33,7 @@ class InferencePipelineRetrieveResponseTest { .name("production") .passingGoalCount(5L) .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(InferencePipelineRetrieveResponse.Status.QUEUED) + .status(InferencePipelineRetrieveResponse.Status.COMPLETED) .statusMessage("Tests successfully evaluated") .totalGoalCount(6L) .project( @@ -89,23 +91,20 @@ class InferencePipelineRetrieveResponseTest { .projectCount(0L) .slug("openlayer") .status(InferencePipelineRetrieveResponse.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - InferencePipelineRetrieveResponse.Workspace.MonthlyUsage.builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) + .addMonthlyUsage( + InferencePipelineRetrieveResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() ) .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) + .addWildcardDomain("string") .build() ) .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") .build() - assertThat(inferencePipelineRetrieveResponse).isNotNull + assertThat(inferencePipelineRetrieveResponse.id()) .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") assertThat(inferencePipelineRetrieveResponse.dateCreated()) @@ -134,7 +133,7 @@ class InferencePipelineRetrieveResponseTest { assertThat(inferencePipelineRetrieveResponse.projectId()) .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") assertThat(inferencePipelineRetrieveResponse.status()) - .isEqualTo(InferencePipelineRetrieveResponse.Status.QUEUED) + .isEqualTo(InferencePipelineRetrieveResponse.Status.COMPLETED) assertThat(inferencePipelineRetrieveResponse.statusMessage()) .contains("Tests successfully evaluated") assertThat(inferencePipelineRetrieveResponse.totalGoalCount()).isEqualTo(6L) @@ -195,21 +194,123 @@ class InferencePipelineRetrieveResponseTest { .projectCount(0L) .slug("openlayer") .status(InferencePipelineRetrieveResponse.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( + .addMonthlyUsage( + InferencePipelineRetrieveResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + assertThat(inferencePipelineRetrieveResponse.workspaceId()) + .contains("055fddb1-261f-4654-8598-f6347ee46a09") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineRetrieveResponse = + InferencePipelineRetrieveResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineRetrieveResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineRetrieveResponse.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineRetrieveResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineRetrieveResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineRetrieveResponse.Project.Source.WEB) + .taskType(InferencePipelineRetrieveResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineRetrieveResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineRetrieveResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineRetrieveResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( InferencePipelineRetrieveResponse.Workspace.MonthlyUsage.builder() .executionTimeMs(0L) .monthYear(LocalDate.parse("2019-12-27")) .predictionCount(0L) .build() ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val roundtrippedInferencePipelineRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineRetrieveResponse), + jacksonTypeRef(), ) - assertThat(inferencePipelineRetrieveResponse.workspaceId()) - .contains("055fddb1-261f-4654-8598-f6347ee46a09") + + assertThat(roundtrippedInferencePipelineRetrieveResponse) + .isEqualTo(inferencePipelineRetrieveResponse) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParamsTest.kt similarity index 60% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParamsTest.kt index 961e64be..f02bcc14 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParamsTest.kt @@ -1,14 +1,14 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InferencePipelineUpdateParamsTest { +internal class InferencePipelineUpdateParamsTest { @Test - fun createInferencePipelineUpdateParams() { + fun create() { InferencePipelineUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .description("This pipeline is used for production.") @@ -18,41 +18,41 @@ class InferencePipelineUpdateParamsTest { } @Test - fun getBody() { + fun pathParams() { val params = InferencePipelineUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .description("This pipeline is used for production.") - .name("production") - .referenceDatasetUri("referenceDatasetUri") .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.description()).isEqualTo("This pipeline is used for production.") - assertThat(body.name()).isEqualTo("production") - assertThat(body.referenceDatasetUri()).isEqualTo("referenceDatasetUri") + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") } @Test - fun getBodyWithoutOptionalFields() { + fun body() { val params = InferencePipelineUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("This pipeline is used for production.") + .name("production") + .referenceDatasetUri("referenceDatasetUri") .build() - val body = params.getBody() - assertThat(body).isNotNull + + val body = params._body() + + assertThat(body.description()).contains("This pipeline is used for production.") + assertThat(body.name()).contains("production") + assertThat(body.referenceDatasetUri()).contains("referenceDatasetUri") } @Test - fun getPathParam() { + fun bodyWithoutOptionalFields() { val params = InferencePipelineUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - assertThat(params).isNotNull - // path param "inferencePipelineId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + + val body = params._body() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt similarity index 62% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt index 22921ec5..30ad9635 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt @@ -1,16 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.LocalDate import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InferencePipelineUpdateResponseTest { +internal class InferencePipelineUpdateResponseTest { @Test - fun createInferencePipelineUpdateResponse() { + fun create() { val inferencePipelineUpdateResponse = InferencePipelineUpdateResponse.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") @@ -31,7 +33,7 @@ class InferencePipelineUpdateResponseTest { .name("production") .passingGoalCount(5L) .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .status(InferencePipelineUpdateResponse.Status.QUEUED) + .status(InferencePipelineUpdateResponse.Status.COMPLETED) .statusMessage("Tests successfully evaluated") .totalGoalCount(6L) .project( @@ -89,23 +91,20 @@ class InferencePipelineUpdateResponseTest { .projectCount(0L) .slug("openlayer") .status(InferencePipelineUpdateResponse.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - InferencePipelineUpdateResponse.Workspace.MonthlyUsage.builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) + .addMonthlyUsage( + InferencePipelineUpdateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() ) .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) + .addWildcardDomain("string") .build() ) .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") .build() - assertThat(inferencePipelineUpdateResponse).isNotNull + assertThat(inferencePipelineUpdateResponse.id()) .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") assertThat(inferencePipelineUpdateResponse.dateCreated()) @@ -134,7 +133,7 @@ class InferencePipelineUpdateResponseTest { assertThat(inferencePipelineUpdateResponse.projectId()) .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") assertThat(inferencePipelineUpdateResponse.status()) - .isEqualTo(InferencePipelineUpdateResponse.Status.QUEUED) + .isEqualTo(InferencePipelineUpdateResponse.Status.COMPLETED) assertThat(inferencePipelineUpdateResponse.statusMessage()) .contains("Tests successfully evaluated") assertThat(inferencePipelineUpdateResponse.totalGoalCount()).isEqualTo(6L) @@ -195,21 +194,123 @@ class InferencePipelineUpdateResponseTest { .projectCount(0L) .slug("openlayer") .status(InferencePipelineUpdateResponse.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( + .addMonthlyUsage( + InferencePipelineUpdateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + assertThat(inferencePipelineUpdateResponse.workspaceId()) + .contains("055fddb1-261f-4654-8598-f6347ee46a09") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineUpdateResponse = + InferencePipelineUpdateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineUpdateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineUpdateResponse.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineUpdateResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineUpdateResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineUpdateResponse.Project.Source.WEB) + .taskType(InferencePipelineUpdateResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineUpdateResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineUpdateResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineUpdateResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( InferencePipelineUpdateResponse.Workspace.MonthlyUsage.builder() .executionTimeMs(0L) .monthYear(LocalDate.parse("2019-12-27")) .predictionCount(0L) .build() ) - ) - .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) - .build() + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val roundtrippedInferencePipelineUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineUpdateResponse), + jacksonTypeRef(), ) - assertThat(inferencePipelineUpdateResponse.workspaceId()) - .contains("055fddb1-261f-4654-8598-f6347ee46a09") + + assertThat(roundtrippedInferencePipelineUpdateResponse) + .isEqualTo(inferencePipelineUpdateResponse) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParamsTest.kt new file mode 100644 index 00000000..4cfa2546 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParamsTest.kt @@ -0,0 +1,185 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.data + +import com.openlayer.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DataStreamParamsTest { + + @Test + fun create() { + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder().outputColumnName("output").build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + DataStreamParams.Config.ofLlmData( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + assertThat(body.rows()) + .containsExactly( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder().outputColumnName("output").build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + DataStreamParams.Config.ofLlmData( + DataStreamParams.Config.LlmData.builder().outputColumnName("output").build() + ) + ) + assertThat(body.rows()) + .containsExactly( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt new file mode 100644 index 00000000..650b2051 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.data + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DataStreamResponseTest { + + @Test + fun create() { + val dataStreamResponse = + DataStreamResponse.builder().success(DataStreamResponse.Success.TRUE).build() + + assertThat(dataStreamResponse.success()).isEqualTo(DataStreamResponse.Success.TRUE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val dataStreamResponse = + DataStreamResponse.builder().success(DataStreamResponse.Success.TRUE).build() + + val roundtrippedDataStreamResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(dataStreamResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDataStreamResponse).isEqualTo(dataStreamResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParamsTest.kt similarity index 59% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateParamsTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParamsTest.kt index 8eb0ac36..7048734d 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowUpdateParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParamsTest.kt @@ -1,25 +1,24 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.inferencepipelines.rows import com.openlayer.api.core.JsonValue import com.openlayer.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class InferencePipelineRowUpdateParamsTest { +internal class RowUpdateParamsTest { @Test - fun createInferencePipelineRowUpdateParams() { - InferencePipelineRowUpdateParams.builder() + fun create() { + RowUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .inferenceId("inferenceId") .row(JsonValue.from(mapOf())) .config( - InferencePipelineRowUpdateParams.Config.builder() + RowUpdateParams.Config.builder() .groundTruthColumnName("ground_truth") .humanFeedbackColumnName("human_feedback") - .inferenceIdColumnName("id") .latencyColumnName("latency") .timestampColumnName("timestamp") .build() @@ -28,66 +27,82 @@ class InferencePipelineRowUpdateParamsTest { } @Test - fun getQueryParams() { + fun pathParams() { val params = - InferencePipelineRowUpdateParams.builder() + RowUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inferenceId("inferenceId") + .row(JsonValue.from(mapOf())) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RowUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .inferenceId("inferenceId") .row(JsonValue.from(mapOf())) .config( - InferencePipelineRowUpdateParams.Config.builder() + RowUpdateParams.Config.builder() .groundTruthColumnName("ground_truth") .humanFeedbackColumnName("human_feedback") - .inferenceIdColumnName("id") .latencyColumnName("latency") .timestampColumnName("timestamp") .build() ) .build() - val expected = QueryParams.builder() - expected.put("inferenceId", "inferenceId") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("inferenceId", "inferenceId").build()) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = - InferencePipelineRowUpdateParams.builder() + RowUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .inferenceId("inferenceId") .row(JsonValue.from(mapOf())) .build() - val expected = QueryParams.builder() - expected.put("inferenceId", "inferenceId") - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("inferenceId", "inferenceId").build()) } @Test - fun getBody() { + fun body() { val params = - InferencePipelineRowUpdateParams.builder() + RowUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .inferenceId("inferenceId") .row(JsonValue.from(mapOf())) .config( - InferencePipelineRowUpdateParams.Config.builder() + RowUpdateParams.Config.builder() .groundTruthColumnName("ground_truth") .humanFeedbackColumnName("human_feedback") - .inferenceIdColumnName("id") .latencyColumnName("latency") .timestampColumnName("timestamp") .build() ) .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.row()).isEqualTo(JsonValue.from(mapOf())) + + val body = params._body() + + assertThat(body._row()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.config()) - .isEqualTo( - InferencePipelineRowUpdateParams.Config.builder() + .contains( + RowUpdateParams.Config.builder() .groundTruthColumnName("ground_truth") .humanFeedbackColumnName("human_feedback") - .inferenceIdColumnName("id") .latencyColumnName("latency") .timestampColumnName("timestamp") .build() @@ -95,30 +110,16 @@ class InferencePipelineRowUpdateParamsTest { } @Test - fun getBodyWithoutOptionalFields() { + fun bodyWithoutOptionalFields() { val params = - InferencePipelineRowUpdateParams.builder() + RowUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .inferenceId("inferenceId") .row(JsonValue.from(mapOf())) .build() - val body = params.getBody() - assertThat(body).isNotNull - assertThat(body.row()).isEqualTo(JsonValue.from(mapOf())) - } - @Test - fun getPathParam() { - val params = - InferencePipelineRowUpdateParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .inferenceId("inferenceId") - .row(JsonValue.from(mapOf())) - .build() - assertThat(params).isNotNull - // path param "inferencePipelineId" - assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - // out-of-bound path param - assertThat(params.getPathParam(1)).isEqualTo("") + val body = params._body() + + assertThat(body._row()).isEqualTo(JsonValue.from(mapOf())) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt new file mode 100644 index 00000000..102493a0 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RowUpdateResponseTest { + + @Test + fun create() { + val rowUpdateResponse = + RowUpdateResponse.builder().success(RowUpdateResponse.Success.TRUE).build() + + assertThat(rowUpdateResponse.success()).isEqualTo(RowUpdateResponse.Success.TRUE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rowUpdateResponse = + RowUpdateResponse.builder().success(RowUpdateResponse.Success.TRUE).build() + + val roundtrippedRowUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rowUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRowUpdateResponse).isEqualTo(rowUpdateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParamsTest.kt new file mode 100644 index 00000000..4def730e --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.testresults + +import com.openlayer.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TestResultListParamsTest { + + @Test + fun create() { + TestResultListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) + .build() + } + + @Test + fun pathParams() { + val params = + TestResultListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + TestResultListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("page", "1") + .put("perPage", "1") + .put("status", "passing") + .put("type", "integrity") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + TestResultListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt new file mode 100644 index 00000000..f0c7244a --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.testresults + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TestResultListResponseTest { + + @Test + fun create() { + val testResultListResponse = + TestResultListResponse.builder() + .addItem( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.PASSING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .build() + + assertThat(testResultListResponse.items()) + .containsExactly( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.PASSING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val testResultListResponse = + TestResultListResponse.builder() + .addItem( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.PASSING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .build() + + val roundtrippedTestResultListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(testResultListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTestResultListResponse).isEqualTo(testResultListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateParamsTest.kt new file mode 100644 index 00000000..e9c15aa9 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateParamsTest.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProjectCreateParamsTest { + + @Test + fun create() { + ProjectCreateParams.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectCreateParams.Source.WEB) + .taskType(ProjectCreateParams.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectCreateParams.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + ProjectCreateParams.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectCreateParams.Source.WEB) + .taskType(ProjectCreateParams.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectCreateParams.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.creatorId()).contains("589ece63-49a2-41b4-98e1-10547761d4b0") + assertThat(body.dateCreated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateUpdated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.developmentGoalCount()).isEqualTo(5L) + assertThat(body.goalCount()).isEqualTo(10L) + assertThat(body.inferencePipelineCount()).isEqualTo(1L) + assertThat(body.links()) + .isEqualTo( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + assertThat(body.monitoringGoalCount()).isEqualTo(5L) + assertThat(body.name()).isEqualTo("My Project") + assertThat(body.source()).contains(ProjectCreateParams.Source.WEB) + assertThat(body.taskType()).isEqualTo(ProjectCreateParams.TaskType.LLM_BASE) + assertThat(body.versionCount()).isEqualTo(2L) + assertThat(body.workspaceId()).contains("055fddb1-261f-4654-8598-f6347ee46a09") + assertThat(body.description()).contains("My project description.") + assertThat(body.gitRepo()) + .contains( + ProjectCreateParams.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ProjectCreateParams.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectCreateParams.Source.WEB) + .taskType(ProjectCreateParams.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.creatorId()).contains("589ece63-49a2-41b4-98e1-10547761d4b0") + assertThat(body.dateCreated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateUpdated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.developmentGoalCount()).isEqualTo(5L) + assertThat(body.goalCount()).isEqualTo(10L) + assertThat(body.inferencePipelineCount()).isEqualTo(1L) + assertThat(body.links()) + .isEqualTo( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + assertThat(body.monitoringGoalCount()).isEqualTo(5L) + assertThat(body.name()).isEqualTo("My Project") + assertThat(body.source()).contains(ProjectCreateParams.Source.WEB) + assertThat(body.taskType()).isEqualTo(ProjectCreateParams.TaskType.LLM_BASE) + assertThat(body.versionCount()).isEqualTo(2L) + assertThat(body.workspaceId()).contains("055fddb1-261f-4654-8598-f6347ee46a09") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt similarity index 64% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateResponseTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt index 86144f76..9eae557b 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCreateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt @@ -1,15 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.projects +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectCreateResponseTest { +internal class ProjectCreateResponseTest { @Test - fun createProjectCreateResponse() { + fun create() { val projectCreateResponse = ProjectCreateResponse.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") @@ -50,7 +52,7 @@ class ProjectCreateResponseTest { .build() ) .build() - assertThat(projectCreateResponse).isNotNull + assertThat(projectCreateResponse.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") assertThat(projectCreateResponse.creatorId()) .contains("589ece63-49a2-41b4-98e1-10547761d4b0") @@ -96,4 +98,57 @@ class ProjectCreateResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val projectCreateResponse = + ProjectCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectCreateResponse.Source.WEB) + .taskType(ProjectCreateResponse.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectCreateResponse.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + + val roundtrippedProjectCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(projectCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProjectCreateResponse).isEqualTo(projectCreateResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListParamsTest.kt similarity index 52% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectListParamsTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListParamsTest.kt index f7f63bf8..3b17b106 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectListParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListParamsTest.kt @@ -1,15 +1,15 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.models +package com.openlayer.api.models.projects import com.openlayer.api.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -class ProjectListParamsTest { +internal class ProjectListParamsTest { @Test - fun createProjectListParams() { + fun create() { ProjectListParams.builder() .name("name") .page(1L) @@ -19,7 +19,7 @@ class ProjectListParamsTest { } @Test - fun getQueryParams() { + fun queryParams() { val params = ProjectListParams.builder() .name("name") @@ -27,18 +27,26 @@ class ProjectListParamsTest { .perPage(1L) .taskType(ProjectListParams.TaskType.LLM_BASE) .build() - val expected = QueryParams.builder() - expected.put("name", "name") - expected.put("page", "1") - expected.put("perPage", "1") - expected.put("taskType", ProjectListParams.TaskType.LLM_BASE.toString()) - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("name", "name") + .put("page", "1") + .put("perPage", "1") + .put("taskType", "llm-base") + .build() + ) } @Test - fun getQueryParamsWithoutOptionalFields() { + fun queryParamsWithoutOptionalFields() { val params = ProjectListParams.builder().build() - val expected = QueryParams.builder() - assertThat(params.getQueryParams()).isEqualTo(expected.build()) + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt new file mode 100644 index 00000000..5b68ccac --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProjectListResponseTest { + + @Test + fun create() { + val projectListResponse = + ProjectListResponse.builder() + .addItem( + ProjectListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectListResponse.Item.Source.WEB) + .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectListResponse.Item.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .build() + + assertThat(projectListResponse.items()) + .containsExactly( + ProjectListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectListResponse.Item.Source.WEB) + .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectListResponse.Item.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val projectListResponse = + ProjectListResponse.builder() + .addItem( + ProjectListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectListResponse.Item.Source.WEB) + .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectListResponse.Item.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .build() + + val roundtrippedProjectListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(projectListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProjectListResponse).isEqualTo(projectListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParamsTest.kt new file mode 100644 index 00000000..063b196d --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParamsTest.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitCreateParamsTest { + + @Test + fun create() { + CommitCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateParams.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + CommitCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateParams.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + CommitCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateParams.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.commit()) + .isEqualTo( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + assertThat(body.dateArchived()).contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateCreated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.failingGoalCount()).isEqualTo(1L) + assertThat(body.mlModelId()).contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.passingGoalCount()).isEqualTo(5L) + assertThat(body.bodyProjectId()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.status()).isEqualTo(CommitCreateParams.Status.COMPLETED) + assertThat(body.statusMessage()).contains("Commit successfully processed.") + assertThat(body.storageUri()).isEqualTo("s3://...") + assertThat(body.totalGoalCount()).isEqualTo(6L) + assertThat(body.trainingDatasetId()).contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.validationDatasetId()).contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.archived()).contains(false) + assertThat(body.deploymentStatus()).contains("Deployed") + assertThat(body.links()) + .contains( + CommitCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CommitCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateParams.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.commit()) + .isEqualTo( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + assertThat(body.dateArchived()).contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateCreated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.failingGoalCount()).isEqualTo(1L) + assertThat(body.mlModelId()).contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.passingGoalCount()).isEqualTo(5L) + assertThat(body.bodyProjectId()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.status()).isEqualTo(CommitCreateParams.Status.COMPLETED) + assertThat(body.statusMessage()).contains("Commit successfully processed.") + assertThat(body.storageUri()).isEqualTo("s3://...") + assertThat(body.totalGoalCount()).isEqualTo(6L) + assertThat(body.trainingDatasetId()).contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.validationDatasetId()).contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt new file mode 100644 index 00000000..39dde058 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitCreateResponseTest { + + @Test + fun create() { + val commitCreateResponse = + CommitCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateResponse.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + assertThat(commitCreateResponse.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.commit()) + .isEqualTo( + CommitCreateResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + assertThat(commitCreateResponse.dateArchived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(commitCreateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(commitCreateResponse.failingGoalCount()).isEqualTo(1L) + assertThat(commitCreateResponse.mlModelId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.passingGoalCount()).isEqualTo(5L) + assertThat(commitCreateResponse.projectId()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.status()).isEqualTo(CommitCreateResponse.Status.COMPLETED) + assertThat(commitCreateResponse.statusMessage()).contains("Commit successfully processed.") + assertThat(commitCreateResponse.totalGoalCount()).isEqualTo(6L) + assertThat(commitCreateResponse.trainingDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.validationDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.archived()).contains(false) + assertThat(commitCreateResponse.deploymentStatus()).contains("Deployed") + assertThat(commitCreateResponse.links()) + .contains( + CommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitCreateResponse = + CommitCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateResponse.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + val roundtrippedCommitCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommitCreateResponse).isEqualTo(commitCreateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListParamsTest.kt new file mode 100644 index 00000000..6503483b --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +import com.openlayer.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitListParamsTest { + + @Test + fun create() { + CommitListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + } + + @Test + fun pathParams() { + val params = + CommitListParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + CommitListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("page", "1").put("perPage", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + CommitListParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt new file mode 100644 index 00000000..458550ff --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.commits + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CommitListResponseTest { + + @Test + fun create() { + val commitListResponse = + CommitListResponse.builder() + .addItem( + CommitListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitListResponse.Item.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitListResponse.Item.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + ) + .build() + + assertThat(commitListResponse.items()) + .containsExactly( + CommitListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitListResponse.Item.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitListResponse.Item.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitListResponse = + CommitListResponse.builder() + .addItem( + CommitListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitListResponse.Item.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitListResponse.Item.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedCommitListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommitListResponse).isEqualTo(commitListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParamsTest.kt new file mode 100644 index 00000000..ec1a1c86 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParamsTest.kt @@ -0,0 +1,389 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InferencePipelineCreateParamsTest { + + @Test + fun create() { + InferencePipelineCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateParams.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineCreateParams.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateParams.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateParams.Project.Source.WEB) + .taskType(InferencePipelineCreateParams.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateParams.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineCreateParams.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateParams.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateParams.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + } + + @Test + fun pathParams() { + val params = + InferencePipelineCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateParams.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + InferencePipelineCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateParams.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineCreateParams.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateParams.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateParams.Project.Source.WEB) + .taskType(InferencePipelineCreateParams.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateParams.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineCreateParams.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateParams.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateParams.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.dateCreated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateLastEvaluated()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateLastSampleReceived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateOfNextEvaluation()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateUpdated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.description()).contains("This pipeline is used for production.") + assertThat(body.failingGoalCount()).isEqualTo(1L) + assertThat(body.links()) + .isEqualTo( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + assertThat(body.name()).isEqualTo("production") + assertThat(body.passingGoalCount()).isEqualTo(5L) + assertThat(body.bodyProjectId()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.status()).isEqualTo(InferencePipelineCreateParams.Status.COMPLETED) + assertThat(body.statusMessage()).contains("Tests successfully evaluated") + assertThat(body.totalGoalCount()).isEqualTo(6L) + assertThat(body.project()) + .contains( + InferencePipelineCreateParams.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateParams.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateParams.Project.Source.WEB) + .taskType(InferencePipelineCreateParams.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateParams.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + assertThat(body.workspace()) + .contains( + InferencePipelineCreateParams.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateParams.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateParams.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + assertThat(body.workspaceId()).contains("055fddb1-261f-4654-8598-f6347ee46a09") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InferencePipelineCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateParams.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .build() + + val body = params._body() + + assertThat(body.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.dateCreated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateLastEvaluated()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateLastSampleReceived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateOfNextEvaluation()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.dateUpdated()).isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(body.description()).contains("This pipeline is used for production.") + assertThat(body.failingGoalCount()).isEqualTo(1L) + assertThat(body.links()) + .isEqualTo( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + assertThat(body.name()).isEqualTo("production") + assertThat(body.passingGoalCount()).isEqualTo(5L) + assertThat(body.bodyProjectId()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(body.status()).isEqualTo(InferencePipelineCreateParams.Status.COMPLETED) + assertThat(body.statusMessage()).contains("Tests successfully evaluated") + assertThat(body.totalGoalCount()).isEqualTo(6L) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt new file mode 100644 index 00000000..b6658491 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InferencePipelineCreateResponseTest { + + @Test + fun create() { + val inferencePipelineCreateResponse = + InferencePipelineCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateResponse.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineCreateResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateResponse.Project.Source.WEB) + .taskType(InferencePipelineCreateResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineCreateResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + assertThat(inferencePipelineCreateResponse.id()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(inferencePipelineCreateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineCreateResponse.dateLastEvaluated()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineCreateResponse.dateLastSampleReceived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineCreateResponse.dateOfNextEvaluation()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineCreateResponse.dateUpdated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineCreateResponse.description()) + .contains("This pipeline is used for production.") + assertThat(inferencePipelineCreateResponse.failingGoalCount()).isEqualTo(1L) + assertThat(inferencePipelineCreateResponse.links()) + .isEqualTo( + InferencePipelineCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + assertThat(inferencePipelineCreateResponse.name()).isEqualTo("production") + assertThat(inferencePipelineCreateResponse.passingGoalCount()).isEqualTo(5L) + assertThat(inferencePipelineCreateResponse.projectId()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(inferencePipelineCreateResponse.status()) + .isEqualTo(InferencePipelineCreateResponse.Status.COMPLETED) + assertThat(inferencePipelineCreateResponse.statusMessage()) + .contains("Tests successfully evaluated") + assertThat(inferencePipelineCreateResponse.totalGoalCount()).isEqualTo(6L) + assertThat(inferencePipelineCreateResponse.project()) + .contains( + InferencePipelineCreateResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateResponse.Project.Source.WEB) + .taskType(InferencePipelineCreateResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + assertThat(inferencePipelineCreateResponse.workspace()) + .contains( + InferencePipelineCreateResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + assertThat(inferencePipelineCreateResponse.workspaceId()) + .contains("055fddb1-261f-4654-8598-f6347ee46a09") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineCreateResponse = + InferencePipelineCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateResponse.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineCreateResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateResponse.Project.Source.WEB) + .taskType(InferencePipelineCreateResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineCreateResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val roundtrippedInferencePipelineCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineCreateResponse) + .isEqualTo(inferencePipelineCreateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListParamsTest.kt new file mode 100644 index 00000000..1c520fbe --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +import com.openlayer.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InferencePipelineListParamsTest { + + @Test + fun create() { + InferencePipelineListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .page(1L) + .perPage(1L) + .build() + } + + @Test + fun pathParams() { + val params = + InferencePipelineListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + InferencePipelineListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .page(1L) + .perPage(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("name", "name") + .put("page", "1") + .put("perPage", "1") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + InferencePipelineListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt new file mode 100644 index 00000000..234dc317 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.projects.inferencepipelines + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InferencePipelineListResponseTest { + + @Test + fun create() { + val inferencePipelineListResponse = + InferencePipelineListResponse.builder() + .addItem( + InferencePipelineListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineListResponse.Item.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineListResponse.Item.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineListResponse.Item.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineListResponse.Item.Project.Source.WEB) + .taskType( + InferencePipelineListResponse.Item.Project.TaskType.LLM_BASE + ) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineListResponse.Item.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .dateUpdated( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineListResponse.Item.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineListResponse.Item.Workspace.MonthlyUsage + .builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + ) + .build() + + assertThat(inferencePipelineListResponse.items()) + .containsExactly( + InferencePipelineListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineListResponse.Item.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineListResponse.Item.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineListResponse.Item.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineListResponse.Item.Project.Source.WEB) + .taskType(InferencePipelineListResponse.Item.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineListResponse.Item.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineListResponse.Item.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineListResponse.Item.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineListResponse = + InferencePipelineListResponse.builder() + .addItem( + InferencePipelineListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineListResponse.Item.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineListResponse.Item.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineListResponse.Item.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineListResponse.Item.Project.Source.WEB) + .taskType( + InferencePipelineListResponse.Item.Project.TaskType.LLM_BASE + ) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineListResponse.Item.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .dateUpdated( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineListResponse.Item.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineListResponse.Item.Workspace.MonthlyUsage + .builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + ) + .build() + + val roundtrippedInferencePipelineListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineListResponse) + .isEqualTo(inferencePipelineListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateParamsTest.kt new file mode 100644 index 00000000..d9c2b5a9 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.storage.presignedurl + +import com.openlayer.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PresignedUrlCreateParamsTest { + + @Test + fun create() { + PresignedUrlCreateParams.builder().objectName("objectName").build() + } + + @Test + fun queryParams() { + val params = PresignedUrlCreateParams.builder().objectName("objectName").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("objectName", "objectName").build()) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt new file mode 100644 index 00000000..7ae0134d --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.storage.presignedurl + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PresignedUrlCreateResponseTest { + + @Test + fun create() { + val presignedUrlCreateResponse = + PresignedUrlCreateResponse.builder() + .storageUri("storageUri") + .url("url") + .fields(JsonValue.from(mapOf())) + .build() + + assertThat(presignedUrlCreateResponse.storageUri()).isEqualTo("storageUri") + assertThat(presignedUrlCreateResponse.url()).isEqualTo("url") + assertThat(presignedUrlCreateResponse._fields()) + .isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val presignedUrlCreateResponse = + PresignedUrlCreateResponse.builder() + .storageUri("storageUri") + .url("url") + .fields(JsonValue.from(mapOf())) + .build() + + val roundtrippedPresignedUrlCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(presignedUrlCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPresignedUrlCreateResponse).isEqualTo(presignedUrlCreateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt index b6311545..bcc988e0 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt @@ -2,9 +2,7 @@ package com.openlayer.api.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl -import com.github.tomakehurst.wiremock.client.WireMock.ok import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status import com.github.tomakehurst.wiremock.client.WireMock.stubFor @@ -18,28 +16,34 @@ import com.openlayer.api.core.jsonMapper import com.openlayer.api.errors.BadRequestException import com.openlayer.api.errors.InternalServerException import com.openlayer.api.errors.NotFoundException -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.errors.OpenlayerException import com.openlayer.api.errors.PermissionDeniedException import com.openlayer.api.errors.RateLimitException import com.openlayer.api.errors.UnauthorizedException import com.openlayer.api.errors.UnexpectedStatusCodeException import com.openlayer.api.errors.UnprocessableEntityException -import com.openlayer.api.models.InferencePipelineDataStreamParams -import com.openlayer.api.models.InferencePipelineDataStreamResponse +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.assertThatThrownBy -import org.assertj.core.api.InstanceOfAssertFactories +import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows @WireMockTest -class ErrorHandlingTest { +internal class ErrorHandlingTest { - private val JSON_MAPPER: JsonMapper = jsonMapper() + companion object { - private val OPENLAYER_ERROR: OpenlayerError = - OpenlayerError.builder().putAdditionalProperty("key", JsonValue.from("value")).build() + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) + + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } private lateinit var client: OpenlayerClient @@ -47,733 +51,491 @@ class ErrorHandlingTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OpenlayerOkHttpClient.builder() - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") .build() } @Test - fun dataStream200() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + fun dataStream400() { + val dataService = client.inferencePipelines().data() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() + } - val expected = - InferencePipelineDataStreamResponse.builder() - .success(InferencePipelineDataStreamResponse.Success.TRUE) - .build() - - stubFor(post(anyUrl()).willReturn(ok().withBody(toJson(expected)))) - - assertThat(client.inferencePipelines().data().stream(params)).isEqualTo(expected) + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun dataStream400() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - + fun dataStream401() { + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().put("Foo", "Bar").build(), OPENLAYER_ERROR) - }) - } - - @Test - fun dataStream401() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .build() + } - stubFor( - post(anyUrl()) - .willReturn(status(401).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) - ) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertUnauthorized(e, Headers.builder().put("Foo", "Bar").build(), OPENLAYER_ERROR) - }) + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test fun dataStream403() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) - ) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertPermissionDenied( - e, - Headers.builder().put("Foo", "Bar").build(), - OPENLAYER_ERROR + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) - }) - } + ) - @Test - fun dataStream404() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test + fun dataStream404() { + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertNotFound(e, Headers.builder().put("Foo", "Bar").build(), OPENLAYER_ERROR) - }) - } - - @Test - fun dataStream422() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .build() + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test + fun dataStream422() { + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) - ) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertUnprocessableEntity( - e, - Headers.builder().put("Foo", "Bar").build(), - OPENLAYER_ERROR + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) - }) - } + ) - @Test - fun dataStream429() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() + } + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun dataStream429() { + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertRateLimit(e, Headers.builder().put("Foo", "Bar").build(), OPENLAYER_ERROR) - }) - } - - @Test - fun dataStream500() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .build() + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test + fun dataStream500() { + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) - ) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertInternalServer( - e, - Headers.builder().put("Foo", "Bar").build(), - OPENLAYER_ERROR + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) - }) - } + ) - @Test - fun unexpectedStatusCode() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .build() + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + @Test + fun dataStream999() { + val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) - ) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertUnexpectedStatusCodeException( - e, - 999, - Headers.builder().put("Foo", "Bar").build(), - toJson(OPENLAYER_ERROR) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) ) - }) - } + ) - @Test - fun invalidBody() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() + } - stubFor(post(anyUrl()).willReturn(status(200).withBody("Not JSON"))) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertThat(e) - .isInstanceOf(OpenlayerException::class.java) - .hasMessage("Error reading response") - }) + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test - fun invalidErrorBody() { - val params = - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() + fun dataStreamInvalidJsonBody() { + val dataService = client.inferencePipelines().data() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows { + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() .content("{{ user_query }}") .role("user") .build() ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() ) - .build() - - stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) - - assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) - .satisfies({ e -> - assertBadRequest(e, Headers.builder().build(), OpenlayerError.builder().build()) - }) - } - - private fun toJson(body: T): ByteArray { - return JSON_MAPPER.writeValueAsBytes(body) - } - - private fun assertUnexpectedStatusCodeException( - throwable: Throwable, - statusCode: Int, - headers: Headers, - responseBody: ByteArray - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnexpectedStatusCodeException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(statusCode) - assertThat(e.body()).isEqualTo(String(responseBody)) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertBadRequest(throwable: Throwable, headers: Headers, error: OpenlayerError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(BadRequestException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnauthorized(throwable: Throwable, headers: Headers, error: OpenlayerError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(UnauthorizedException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertPermissionDenied( - throwable: Throwable, - headers: Headers, - error: OpenlayerError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(PermissionDeniedException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertNotFound(throwable: Throwable, headers: Headers, error: OpenlayerError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(NotFoundException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertUnprocessableEntity( - throwable: Throwable, - headers: Headers, - error: OpenlayerError - ) { - assertThat(throwable) - .asInstanceOf( - InstanceOfAssertFactories.throwable(UnprocessableEntityException::class.java) - ) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } - - private fun assertRateLimit(throwable: Throwable, headers: Headers, error: OpenlayerError) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(RateLimitException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) - } + } - private fun assertInternalServer( - throwable: Throwable, - headers: Headers, - error: OpenlayerError - ) { - assertThat(throwable) - .asInstanceOf(InstanceOfAssertFactories.throwable(InternalServerException::class.java)) - .satisfies({ e -> - assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(error) - assertThat(e.headers().toMap()).containsAllEntriesOf(headers.toMap()) - }) + assertThat(e).hasMessage("Error reading response") } private fun Headers.toMap(): Map> = diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ServiceParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ServiceParamsTest.kt index 1348d1bc..28d1a606 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ServiceParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ServiceParamsTest.kt @@ -2,7 +2,6 @@ package com.openlayer.api.services -import com.fasterxml.jackson.databind.json.JsonMapper import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -16,16 +15,12 @@ import com.github.tomakehurst.wiremock.junit5.WireMockTest import com.openlayer.api.client.OpenlayerClient import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.jsonMapper -import com.openlayer.api.models.InferencePipelineDataStreamParams -import com.openlayer.api.models.InferencePipelineDataStreamResponse +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @WireMockTest -class ServiceParamsTest { - - private val JSON_MAPPER: JsonMapper = jsonMapper() +internal class ServiceParamsTest { private lateinit var client: OpenlayerClient @@ -33,85 +28,60 @@ class ServiceParamsTest { fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { client = OpenlayerOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) .apiKey("My API Key") - .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) .build() } @Test - fun dataStreamWithAdditionalParams() { - val additionalHeaders = mutableMapOf>() - - additionalHeaders.put("x-test-header", listOf("abc1234")) - - val additionalQueryParams = mutableMapOf>() - - additionalQueryParams.put("test_query_param", listOf("def567")) - - val additionalBodyProperties = mutableMapOf() - - additionalBodyProperties.put("testBodyProperty", JsonValue.from("ghi890")) + fun stream() { + val dataService = client.inferencePipelines().data() + stubFor(post(anyUrl()).willReturn(ok("{}"))) - val params = - InferencePipelineDataStreamParams.builder() + dataService.stream( + DataStreamParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() ) - .additionalHeaders(additionalHeaders) - .additionalBodyProperties(additionalBodyProperties) - .additionalQueryParams(additionalQueryParams) + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) .build() - - val apiResponse = - InferencePipelineDataStreamResponse.builder() - .success(InferencePipelineDataStreamResponse.Success.TRUE) - .build() - - stubFor( - post(anyUrl()) - .withHeader("x-test-header", equalTo("abc1234")) - .withQueryParam("test_query_param", equalTo("def567")) - .withRequestBody(matchingJsonPath("$.testBodyProperty", equalTo("ghi890"))) - .willReturn(ok(JSON_MAPPER.writeValueAsString(apiResponse))) ) - client.inferencePipelines().data().stream(params) - - verify(postRequestedFor(anyUrl())) + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/CommitServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/CommitServiceAsyncTest.kt new file mode 100644 index 00000000..9696a52f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/CommitServiceAsyncTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.commits.CommitRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommitServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitServiceAsync = client.commits() + + val commitFuture = + commitServiceAsync.retrieve( + CommitRetrieveParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val commit = commitFuture.get() + commit.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt new file mode 100644 index 00000000..31daf776 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InferencePipelineServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineServiceAsync = client.inferencePipelines() + + val inferencePipelineFuture = + inferencePipelineServiceAsync.retrieve( + InferencePipelineRetrieveParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExpand(InferencePipelineRetrieveParams.Expand.PROJECT) + .build() + ) + + val inferencePipeline = inferencePipelineFuture.get() + inferencePipeline.validate() + } + + @Test + fun update() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineServiceAsync = client.inferencePipelines() + + val inferencePipelineFuture = + inferencePipelineServiceAsync.update( + InferencePipelineUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("This pipeline is used for production.") + .name("production") + .referenceDatasetUri("referenceDatasetUri") + .build() + ) + + val inferencePipeline = inferencePipelineFuture.get() + inferencePipeline.validate() + } + + @Test + fun delete() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineServiceAsync = client.inferencePipelines() + + val future = + inferencePipelineServiceAsync.delete( + InferencePipelineDeleteParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = future.get() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncTest.kt new file mode 100644 index 00000000..4685622f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.projects.ProjectCreateParams +import com.openlayer.api.models.projects.ProjectListParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ProjectServiceAsyncTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectFuture = + projectServiceAsync.create( + ProjectCreateParams.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectCreateParams.Source.WEB) + .taskType(ProjectCreateParams.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectCreateParams.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + + val project = projectFuture.get() + project.validate() + } + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectServiceAsync = client.projects() + + val projectsFuture = + projectServiceAsync.list( + ProjectListParams.builder() + .name("name") + .page(1L) + .perPage(1L) + .taskType(ProjectListParams.TaskType.LLM_BASE) + .build() + ) + + val projects = projectsFuture.get() + projects.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncTest.kt new file mode 100644 index 00000000..d9bc2dc4 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.commits + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.commits.testresults.TestResultListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TestResultServiceAsyncTest { + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val testResultServiceAsync = client.commits().testResults() + + val testResultsFuture = + testResultServiceAsync.list( + TestResultListParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(1L) + .perPage(1L) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) + .build() + ) + + val testResults = testResultsFuture.get() + testResults.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncTest.kt new file mode 100644 index 00000000..e1a0cce4 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncTest.kt @@ -0,0 +1,64 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DataServiceAsyncTest { + + @Test + fun stream() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val dataServiceAsync = client.inferencePipelines().data() + + val responseFuture = + dataServiceAsync.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt new file mode 100644 index 00000000..539670bc --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RowServiceAsyncTest { + + @Test + fun update() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val rowServiceAsync = client.inferencePipelines().rows() + + val rowFuture = + rowServiceAsync.update( + RowUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inferenceId("inferenceId") + .row(JsonValue.from(mapOf())) + .config( + RowUpdateParams.Config.builder() + .groundTruthColumnName("ground_truth") + .humanFeedbackColumnName("human_feedback") + .latencyColumnName("latency") + .timestampColumnName("timestamp") + .build() + ) + .build() + ) + + val row = rowFuture.get() + row.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncTest.kt new file mode 100644 index 00000000..c42e5bae --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencepipelines + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TestResultServiceAsyncTest { + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val testResultServiceAsync = client.inferencePipelines().testResults() + + val testResultsFuture = + testResultServiceAsync.list( + TestResultListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) + .build() + ) + + val testResults = testResultsFuture.get() + testResults.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncTest.kt new file mode 100644 index 00000000..3bdcb1a4 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.projects + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.projects.commits.CommitCreateParams +import com.openlayer.api.models.projects.commits.CommitListParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommitServiceAsyncTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitServiceAsync = client.projects().commits() + + val commitFuture = + commitServiceAsync.create( + CommitCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateParams.Status.COMPLETED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + ) + + val commit = commitFuture.get() + commit.validate() + } + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitServiceAsync = client.projects().commits() + + val commitsFuture = + commitServiceAsync.list( + CommitListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + ) + + val commits = commitsFuture.get() + commits.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncTest.kt new file mode 100644 index 00000000..7a76a2c1 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncTest.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.projects + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams +import java.time.LocalDate +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InferencePipelineServiceAsyncTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineServiceAsync = client.projects().inferencePipelines() + + val inferencePipelineFuture = + inferencePipelineServiceAsync.create( + InferencePipelineCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateParams.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineCreateParams.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateParams.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateParams.Project.Source.WEB) + .taskType(InferencePipelineCreateParams.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateParams.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineCreateParams.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateParams.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateParams.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + ) + + val inferencePipeline = inferencePipelineFuture.get() + inferencePipeline.validate() + } + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineServiceAsync = client.projects().inferencePipelines() + + val inferencePipelinesFuture = + inferencePipelineServiceAsync.list( + InferencePipelineListParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .page(1L) + .perPage(1L) + .build() + ) + + val inferencePipelines = inferencePipelinesFuture.get() + inferencePipelines.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncTest.kt new file mode 100644 index 00000000..e98d12f7 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.storage + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PresignedUrlServiceAsyncTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val presignedUrlServiceAsync = client.storage().presignedUrl() + + val presignedUrlFuture = + presignedUrlServiceAsync.create( + PresignedUrlCreateParams.builder().objectName("objectName").build() + ) + + val presignedUrl = presignedUrlFuture.get() + presignedUrl.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/CommitServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/CommitServiceTest.kt new file mode 100644 index 00000000..d9235637 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/CommitServiceTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient +import com.openlayer.api.models.commits.CommitRetrieveParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CommitServiceTest { + + @Test + fun retrieve() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitService = client.commits() + + val commit = + commitService.retrieve( + CommitRetrieveParams.builder() + .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + commit.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt index 4fd11109..ce6a6507 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt @@ -4,43 +4,45 @@ package com.openlayer.api.services.blocking import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.InferencePipelineDeleteParams -import com.openlayer.api.models.InferencePipelineRetrieveParams -import com.openlayer.api.models.InferencePipelineUpdateParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class InferencePipelineServiceTest { +internal class InferencePipelineServiceTest { @Test - fun callRetrieve() { + fun retrieve() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val inferencePipelineService = client.inferencePipelines() - val inferencePipelineRetrieveResponse = + + val inferencePipeline = inferencePipelineService.retrieve( InferencePipelineRetrieveParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .expand(listOf(InferencePipelineRetrieveParams.Expand.PROJECT)) + .addExpand(InferencePipelineRetrieveParams.Expand.PROJECT) .build() ) - println(inferencePipelineRetrieveResponse) - inferencePipelineRetrieveResponse.validate() + + inferencePipeline.validate() } @Test - fun callUpdate() { + fun update() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val inferencePipelineService = client.inferencePipelines() - val inferencePipelineUpdateResponse = + + val inferencePipeline = inferencePipelineService.update( InferencePipelineUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -49,18 +51,19 @@ class InferencePipelineServiceTest { .referenceDatasetUri("referenceDatasetUri") .build() ) - println(inferencePipelineUpdateResponse) - inferencePipelineUpdateResponse.validate() + + inferencePipeline.validate() } @Test - fun callDelete() { + fun delete() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val inferencePipelineService = client.inferencePipelines() + inferencePipelineService.delete( InferencePipelineDeleteParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/ProjectServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/ProjectServiceTest.kt index 13aea9ff..ec241248 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/ProjectServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/ProjectServiceTest.kt @@ -4,43 +4,80 @@ package com.openlayer.api.services.blocking import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.ProjectCreateParams -import com.openlayer.api.models.ProjectListParams +import com.openlayer.api.models.projects.ProjectCreateParams +import com.openlayer.api.models.projects.ProjectListParams +import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class ProjectServiceTest { +internal class ProjectServiceTest { @Test - fun callCreate() { + fun create() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() - val projectCreateResponse = + + val project = projectService.create( ProjectCreateParams.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) .name("My Project") + .source(ProjectCreateParams.Source.WEB) .taskType(ProjectCreateParams.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") .description("My project description.") + .gitRepo( + ProjectCreateParams.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) .build() ) - println(projectCreateResponse) - projectCreateResponse.validate() + + project.validate() } @Test - fun callList() { + fun list() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val projectService = client.projects() - val projectListResponse = + + val projects = projectService.list( ProjectListParams.builder() .name("name") @@ -49,7 +86,7 @@ class ProjectServiceTest { .taskType(ProjectListParams.TaskType.LLM_BASE) .build() ) - println(projectListResponse) - projectListResponse.validate() + + projects.validate() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceTest.kt index 0cdb2624..ed3c4923 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceTest.kt @@ -4,33 +4,34 @@ package com.openlayer.api.services.blocking.commits import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.CommitTestResultListParams +import com.openlayer.api.models.commits.testresults.TestResultListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class TestResultServiceTest { +internal class TestResultServiceTest { @Test - fun callList() { + fun list() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val testResultService = client.commits().testResults() - val commitTestResultListResponse = + + val testResults = testResultService.list( - CommitTestResultListParams.builder() + TestResultListParams.builder() .projectVersionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .includeArchived(true) .page(1L) .perPage(1L) - .status(CommitTestResultListParams.Status.RUNNING) - .type(CommitTestResultListParams.Type.INTEGRITY) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) .build() ) - println(commitTestResultListResponse) - commitTestResultListResponse.validate() + + testResults.validate() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataServiceTest.kt deleted file mode 100644 index 1146339a..00000000 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/DataServiceTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.services.blocking.inferencePipelines - -import com.openlayer.api.TestServerExtension -import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.core.JsonValue -import com.openlayer.api.models.InferencePipelineDataStreamParams -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -class DataServiceTest { - - @Test - fun callStream() { - val client = - OpenlayerOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val dataService = client.inferencePipelines().data() - val inferencePipelineDataStreamResponse = - dataService.stream( - InferencePipelineDataStreamParams.builder() - .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - InferencePipelineDataStreamParams.Config.ofLlmData( - InferencePipelineDataStreamParams.Config.LlmData.builder() - .outputColumnName("output") - .contextColumnName("context") - .costColumnName("cost") - .groundTruthColumnName("ground_truth") - .inferenceIdColumnName("id") - .inputVariableNames(listOf("user_query")) - .latencyColumnName("latency") - .metadata(JsonValue.from(mapOf())) - .numOfTokenColumnName("tokens") - .prompt( - listOf( - InferencePipelineDataStreamParams.Config.LlmData.Prompt - .builder() - .content("{{ user_query }}") - .role("user") - .build() - ) - ) - .questionColumnName("question") - .timestampColumnName("timestamp") - .build() - ) - ) - .rows( - listOf( - InferencePipelineDataStreamParams.Row.builder() - .putAdditionalProperty("user_query", JsonValue.from("bar")) - .putAdditionalProperty("output", JsonValue.from("bar")) - .putAdditionalProperty("tokens", JsonValue.from("bar")) - .putAdditionalProperty("cost", JsonValue.from("bar")) - .putAdditionalProperty("timestamp", JsonValue.from("bar")) - .build() - ) - ) - .build() - ) - println(inferencePipelineDataStreamResponse) - inferencePipelineDataStreamResponse.validate() - } -} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceTest.kt new file mode 100644 index 00000000..fc46b195 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencepipelines + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient +import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.inferencepipelines.data.DataStreamParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DataServiceTest { + + @Test + fun stream() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val dataService = client.inferencePipelines().data() + + val response = + dataService.stream( + DataStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + DataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .contextColumnName("context") + .costColumnName("cost") + .groundTruthColumnName("ground_truth") + .inferenceIdColumnName("id") + .addInputVariableName("user_query") + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("tokens") + .addPrompt( + DataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + .addRow( + DataStreamParams.Row.builder() + .putAdditionalProperty("user_query", JsonValue.from("bar")) + .putAdditionalProperty("output", JsonValue.from("bar")) + .putAdditionalProperty("tokens", JsonValue.from("bar")) + .putAdditionalProperty("cost", JsonValue.from("bar")) + .putAdditionalProperty("timestamp", JsonValue.from("bar")) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt similarity index 69% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt index dacce1df..847f7b18 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt @@ -1,43 +1,43 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.services.blocking.inferencePipelines +package com.openlayer.api.services.blocking.inferencepipelines import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient import com.openlayer.api.core.JsonValue -import com.openlayer.api.models.InferencePipelineRowUpdateParams +import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class RowServiceTest { +internal class RowServiceTest { @Test - fun callUpdate() { + fun update() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val rowService = client.inferencePipelines().rows() - val inferencePipelineRowUpdateResponse = + + val row = rowService.update( - InferencePipelineRowUpdateParams.builder() + RowUpdateParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .inferenceId("inferenceId") .row(JsonValue.from(mapOf())) .config( - InferencePipelineRowUpdateParams.Config.builder() + RowUpdateParams.Config.builder() .groundTruthColumnName("ground_truth") .humanFeedbackColumnName("human_feedback") - .inferenceIdColumnName("id") .latencyColumnName("latency") .timestampColumnName("timestamp") .build() ) .build() ) - println(inferencePipelineRowUpdateResponse) - inferencePipelineRowUpdateResponse.validate() + + row.validate() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceTest.kt similarity index 57% rename from openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultServiceTest.kt rename to openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceTest.kt index 21524e9f..876a2f61 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/TestResultServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceTest.kt @@ -1,35 +1,36 @@ // File generated from our OpenAPI spec by Stainless. -package com.openlayer.api.services.blocking.inferencePipelines +package com.openlayer.api.services.blocking.inferencepipelines import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.InferencePipelineTestResultListParams +import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class TestResultServiceTest { +internal class TestResultServiceTest { @Test - fun callList() { + fun list() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val testResultService = client.inferencePipelines().testResults() - val inferencePipelineTestResultListResponse = + + val testResults = testResultService.list( - InferencePipelineTestResultListParams.builder() + TestResultListParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .page(1L) .perPage(1L) - .status(InferencePipelineTestResultListParams.Status.RUNNING) - .type(InferencePipelineTestResultListParams.Type.INTEGRITY) + .status(TestResultListParams.Status.PASSING) + .type(TestResultListParams.Type.INTEGRITY) .build() ) - println(inferencePipelineTestResultListResponse) - inferencePipelineTestResultListResponse.validate() + + testResults.validate() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt index 8bafae36..123a0e55 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt @@ -4,29 +4,31 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.ProjectCommitCreateParams -import com.openlayer.api.models.ProjectCommitListParams +import com.openlayer.api.models.projects.commits.CommitCreateParams +import com.openlayer.api.models.projects.commits.CommitListParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class CommitServiceTest { +internal class CommitServiceTest { @Test - fun callCreate() { + fun create() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val commitService = client.projects().commits() - val projectCommitCreateResponse = + + val commit = commitService.create( - ProjectCommitCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + CommitCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") .commit( - ProjectCommitCreateParams.Commit.builder() + CommitCreateParams.Commit.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") .fileSize(1024L) @@ -41,32 +43,51 @@ class CommitServiceTest { .gitCommitUrl("gitCommitUrl") .build() ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateParams.Status.COMPLETED) + .statusMessage("Commit successfully processed.") .storageUri("s3://...") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") .archived(false) .deploymentStatus("Deployed") + .links( + CommitCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) .build() ) - println(projectCommitCreateResponse) - projectCommitCreateResponse.validate() + + commit.validate() } @Test - fun callList() { + fun list() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val commitService = client.projects().commits() - val projectCommitListResponse = + + val commits = commitService.list( - ProjectCommitListParams.builder() + CommitListParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .page(1L) .perPage(1L) .build() ) - println(projectCommitListResponse) - projectCommitListResponse.validate() + + commits.validate() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceTest.kt index c7a80a4e..e976bf54 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceTest.kt @@ -4,32 +4,52 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.ProjectInferencePipelineCreateParams -import com.openlayer.api.models.ProjectInferencePipelineListParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams +import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams import java.time.LocalDate import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class InferencePipelineServiceTest { +internal class InferencePipelineServiceTest { @Test - fun callCreate() { + fun create() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val inferencePipelineService = client.projects().inferencePipelines() - val projectInferencePipelineCreateResponse = + + val inferencePipeline = inferencePipelineService.create( - ProjectInferencePipelineCreateParams.builder() - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + InferencePipelineCreateParams.builder() + .pathProjectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateParams.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) .name("production") + .passingGoalCount(5L) + .bodyProjectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateParams.Status.COMPLETED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) .project( - ProjectInferencePipelineCreateParams.Project.builder() + InferencePipelineCreateParams.Project.builder() .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) @@ -38,7 +58,7 @@ class InferencePipelineServiceTest { .goalCount(10L) .inferencePipelineCount(1L) .links( - ProjectInferencePipelineCreateParams.Project.Links.builder() + InferencePipelineCreateParams.Project.Links.builder() .app( "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" ) @@ -46,15 +66,13 @@ class InferencePipelineServiceTest { ) .monitoringGoalCount(5L) .name("My Project") - .source(ProjectInferencePipelineCreateParams.Project.Source.WEB) - .taskType( - ProjectInferencePipelineCreateParams.Project.TaskType.LLM_BASE - ) + .source(InferencePipelineCreateParams.Project.Source.WEB) + .taskType(InferencePipelineCreateParams.Project.TaskType.LLM_BASE) .versionCount(2L) .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") .description("My project description.") .gitRepo( - ProjectInferencePipelineCreateParams.Project.GitRepo.builder() + InferencePipelineCreateParams.Project.GitRepo.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -72,7 +90,7 @@ class InferencePipelineServiceTest { .build() ) .workspace( - ProjectInferencePipelineCreateParams.Workspace.builder() + InferencePipelineCreateParams.Workspace.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -84,46 +102,44 @@ class InferencePipelineServiceTest { .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .projectCount(0L) .slug("openlayer") - .status(ProjectInferencePipelineCreateParams.Workspace.Status.ACTIVE) - .inviteCode("inviteCode") - .monthlyUsage( - listOf( - ProjectInferencePipelineCreateParams.Workspace.MonthlyUsage - .builder() - .executionTimeMs(0L) - .monthYear(LocalDate.parse("2019-12-27")) - .predictionCount(0L) - .build() - ) + .status(InferencePipelineCreateParams.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateParams.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() ) .samlOnlyAccess(true) - .wildcardDomains(listOf("string")) + .addWildcardDomain("string") .build() ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") .build() ) - println(projectInferencePipelineCreateResponse) - projectInferencePipelineCreateResponse.validate() + + inferencePipeline.validate() } @Test - fun callList() { + fun list() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val inferencePipelineService = client.projects().inferencePipelines() - val projectInferencePipelineListResponse = + + val inferencePipelines = inferencePipelineService.list( - ProjectInferencePipelineListParams.builder() + InferencePipelineListParams.builder() .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("name") .page(1L) .perPage(1L) .build() ) - println(projectInferencePipelineListResponse) - projectInferencePipelineListResponse.validate() + + inferencePipelines.validate() } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceTest.kt index c2986d3e..f165113e 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceTest.kt @@ -4,26 +4,27 @@ package com.openlayer.api.services.blocking.storage import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient -import com.openlayer.api.models.StoragePresignedUrlCreateParams +import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -class PresignedUrlServiceTest { +internal class PresignedUrlServiceTest { @Test - fun callCreate() { + fun create() { val client = OpenlayerOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() val presignedUrlService = client.storage().presignedUrl() - val storagePresignedUrlCreateResponse = + + val presignedUrl = presignedUrlService.create( - StoragePresignedUrlCreateParams.builder().objectName("objectName").build() + PresignedUrlCreateParams.builder().objectName("objectName").build() ) - println(storagePresignedUrlCreateResponse) - storagePresignedUrlCreateResponse.validate() + + presignedUrl.validate() } } diff --git a/openlayer-java-example/build.gradle.kts b/openlayer-java-example/build.gradle.kts index 9973e516..24ee916a 100644 --- a/openlayer-java-example/build.gradle.kts +++ b/openlayer-java-example/build.gradle.kts @@ -1,9 +1,12 @@ plugins { - id("openlayer.kotlin") - id("java") + id("openlayer.java") application } +repositories { + mavenCentral() +} + dependencies { implementation(project(":openlayer-java")) } diff --git a/openlayer-java/build.gradle.kts b/openlayer-java/build.gradle.kts index a4d8ebbd..9fd76f1f 100644 --- a/openlayer-java/build.gradle.kts +++ b/openlayer-java/build.gradle.kts @@ -6,3 +6,24 @@ plugins { dependencies { api(project(":openlayer-java-client-okhttp")) } + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/scripts/format b/scripts/format index c6239fab..456a69db 100755 --- a/scripts/format +++ b/scripts/format @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Running spotlessApply" -./gradlew --build-cache --parallel --no-daemon spotlessApply +./gradlew spotlessApply diff --git a/scripts/lint b/scripts/lint index 58753d0b..e3a5f5e2 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Build classes" -./gradlew --build-cache --parallel --no-daemon build testClasses -x test +./gradlew build testClasses -x test diff --git a/scripts/test b/scripts/test index 72ed0333..6b750a74 100755 --- a/scripts/test +++ b/scripts/test @@ -53,4 +53,4 @@ else fi echo "==> Running tests" -./gradlew --build-cache --parallel --no-daemon test +./gradlew test