From 6cb740885ec6cc7d489d2235473c6c412811d406 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:55:07 +0000 Subject: [PATCH 1/2] feat(api): update via SDK Studio (#1) --- .devcontainer/Dockerfile | 23 + .devcontainer/devcontainer.json | 20 + .gitattributes | 5 + .github/workflows/ci.yml | 36 + .github/workflows/publish-sonatype.yml | 39 + .github/workflows/release-doctor.yml | 23 + .gitignore | 5 + .release-please-manifest.json | 3 + .stats.yml | 1 + LICENSE | 201 ++ README.md | 253 +- SECURITY.md | 27 + bin/check-release-environment | 44 + build.gradle.kts | 20 + buildSrc/build.gradle.kts | 12 + .../src/main/kotlin/openlayer.java.gradle.kts | 57 + .../main/kotlin/openlayer.kotlin.gradle.kts | 27 + .../main/kotlin/openlayer.publish.gradle.kts | 67 + examples/.keep | 4 + gradle.properties | 4 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 43453 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 249 ++ gradlew.bat | 92 + openlayer-java-client-okhttp/build.gradle.kts | 15 + .../openlayer/client/okhttp/OkHttpClient.kt | 202 ++ .../client/okhttp/OpenlayerOkHttpClient.kt | 83 + .../okhttp/OpenlayerOkHttpClientAsync.kt | 83 + openlayer-java-core/build.gradle.kts | 26 + .../org/openlayer/client/OpenlayerClient.kt | 19 + .../openlayer/client/OpenlayerClientAsync.kt | 19 + .../client/OpenlayerClientAsyncImpl.kt | 36 + .../openlayer/client/OpenlayerClientImpl.kt | 36 + .../org/openlayer/core/BaseDeserializer.kt | 59 + .../org/openlayer/core/BaseSerializer.kt | 6 + .../org/openlayer/core/ClientOptions.kt | 134 + .../org/openlayer/core/ObjectMappers.kt | 25 + .../kotlin/org/openlayer/core/Properties.kt | 47 + .../org/openlayer/core/RequestOptions.kt | 40 + .../main/kotlin/org/openlayer/core/Utils.kt | 61 + .../main/kotlin/org/openlayer/core/Values.kt | 535 ++++ .../core/http/BinaryResponseContent.kt | 15 + .../org/openlayer/core/http/HttpClient.kt | 18 + .../org/openlayer/core/http/HttpMethod.kt | 13 + .../org/openlayer/core/http/HttpRequest.kt | 92 + .../openlayer/core/http/HttpRequestBody.kt | 25 + .../org/openlayer/core/http/HttpResponse.kt | 19 + .../openlayer/core/http/RetryingHttpClient.kt | 246 ++ .../openlayer/errors/BadRequestException.kt | 13 + .../errors/InternalServerException.kt | 14 + .../org/openlayer/errors/NotFoundException.kt | 13 + .../org/openlayer/errors/OpenlayerError.kt | 65 + .../openlayer/errors/OpenlayerException.kt | 5 + .../errors/OpenlayerInvalidDataException.kt | 5 + .../openlayer/errors/OpenlayerIoException.kt | 5 + .../errors/OpenlayerServiceException.kt | 15 + .../errors/PermissionDeniedException.kt | 13 + .../openlayer/errors/RateLimitException.kt | 13 + .../openlayer/errors/UnauthorizedException.kt | 13 + .../errors/UnexpectedStatusCodeException.kt | 14 + .../errors/UnprocessableEntityException.kt | 13 + .../models/CommitTestResultListParams.kt | 377 +++ .../models/CommitTestResultListResponse.kt | 1664 ++++++++++++ .../InferencePipelineDataStreamParams.kt | 2236 +++++++++++++++++ .../InferencePipelineDataStreamResponse.kt | 161 ++ .../InferencePipelineTestResultListParams.kt | 379 +++ ...InferencePipelineTestResultListResponse.kt | 1666 ++++++++++++ .../models/ProjectCommitListParams.kt | 179 ++ .../models/ProjectCommitListResponse.kt | 1308 ++++++++++ .../ProjectInferencePipelineListParams.kt | 194 ++ .../ProjectInferencePipelineListResponse.kt | 1017 ++++++++ .../org/openlayer/models/ProjectListParams.kt | 259 ++ .../openlayer/models/ProjectListResponse.kt | 1381 ++++++++++ .../kotlin/org/openlayer/services/Handlers.kt | 130 + .../openlayer/services/HttpRequestBodies.kt | 114 + .../services/async/CommitServiceAsync.kt | 12 + .../services/async/CommitServiceAsyncImpl.kt | 24 + .../async/InferencePipelineServiceAsync.kt | 15 + .../InferencePipelineServiceAsyncImpl.kt | 30 + .../services/async/ProjectServiceAsync.kt | 26 + .../services/async/ProjectServiceAsyncImpl.kt | 67 + .../async/commits/TestResultServiceAsync.kt | 20 + .../commits/TestResultServiceAsyncImpl.kt | 54 + .../inferencePipelines/DataServiceAsync.kt | 20 + .../DataServiceAsyncImpl.kt | 56 + .../TestResultServiceAsync.kt | 20 + .../TestResultServiceAsyncImpl.kt | 54 + .../async/projects/CommitServiceAsync.kt | 20 + .../async/projects/CommitServiceAsyncImpl.kt | 54 + .../projects/InferencePipelineServiceAsync.kt | 20 + .../InferencePipelineServiceAsyncImpl.kt | 54 + .../services/blocking/CommitService.kt | 12 + .../services/blocking/CommitServiceImpl.kt | 22 + .../blocking/InferencePipelineService.kt | 15 + .../blocking/InferencePipelineServiceImpl.kt | 28 + .../services/blocking/ProjectService.kt | 25 + .../services/blocking/ProjectServiceImpl.kt | 65 + .../blocking/commits/TestResultService.kt | 19 + .../blocking/commits/TestResultServiceImpl.kt | 52 + .../inferencePipelines/DataService.kt | 19 + .../inferencePipelines/DataServiceImpl.kt | 54 + .../inferencePipelines/TestResultService.kt | 19 + .../TestResultServiceImpl.kt | 52 + .../blocking/projects/CommitService.kt | 19 + .../blocking/projects/CommitServiceImpl.kt | 52 + .../projects/InferencePipelineService.kt | 19 + .../projects/InferencePipelineServiceImpl.kt | 52 + .../org/openlayer/TestServerExtension.kt | 62 + .../openlayer/client/OpenlayerClientTest.kt | 5 + .../openlayer/core/http/HttpRequestTest.kt | 22 + .../core/http/RetryingHttpClientTest.kt | 111 + .../org/openlayer/core/http/SerializerTest.kt | 105 + .../models/CommitTestResultListParamsTest.kt | 61 + .../CommitTestResultListResponseTest.kt | 154 ++ .../InferencePipelineDataStreamParamsTest.kt | 158 ++ ...InferencePipelineDataStreamResponseTest.kt | 20 + ...ferencePipelineTestResultListParamsTest.kt | 71 + ...rencePipelineTestResultListResponseTest.kt | 160 ++ .../models/ProjectCommitListParamsTest.kt | 52 + .../models/ProjectCommitListResponseTest.kt | 124 + .../ProjectInferencePipelineListParamsTest.kt | 59 + ...rojectInferencePipelineListResponseTest.kt | 98 + .../openlayer/models/ProjectListParamsTest.kt | 44 + .../models/ProjectListResponseTest.kt | 132 + .../openlayer/services/ErrorHandlingTest.kt | 679 +++++ .../openlayer/services/ServiceParamsTest.kt | 109 + .../services/blocking/CommitServiceTest.kt | 9 + .../blocking/InferencePipelineServiceTest.kt | 9 + .../services/blocking/ProjectServiceTest.kt | 34 + .../blocking/commits/TestResultServiceTest.kt | 36 + .../inferencePipelines/DataServiceTest.kt | 59 + .../TestResultServiceTest.kt | 36 + .../blocking/projects/CommitServiceTest.kt | 33 + .../projects/InferencePipelineServiceTest.kt | 34 + openlayer-java-lib/.keep | 4 + openlayer-java/build.gradle.kts | 8 + release-please-config.json | 67 + scripts/format | 8 + scripts/lint | 8 + scripts/mock | 41 + scripts/test | 56 + settings.gradle.kts | 6 + 142 files changed, 18082 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitattributes create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/publish-sonatype.yml create mode 100644 .github/workflows/release-doctor.yml create mode 100644 .gitignore create mode 100644 .release-please-manifest.json create mode 100644 .stats.yml create mode 100644 LICENSE create mode 100644 SECURITY.md create mode 100644 bin/check-release-environment create mode 100644 build.gradle.kts create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/openlayer.java.gradle.kts create mode 100644 buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts create mode 100644 buildSrc/src/main/kotlin/openlayer.publish.gradle.kts create mode 100644 examples/.keep create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100755 gradlew create mode 100644 gradlew.bat create mode 100644 openlayer-java-client-okhttp/build.gradle.kts create mode 100644 openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OkHttpClient.kt create mode 100644 openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClient.kt create mode 100644 openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClientAsync.kt create mode 100644 openlayer-java-core/build.gradle.kts create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClient.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseDeserializer.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseSerializer.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/ClientOptions.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/ObjectMappers.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/Properties.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/RequestOptions.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/Utils.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/Values.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/BinaryResponseContent.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpClient.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpMethod.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequest.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequestBody.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/core/http/RetryingHttpClient.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/BadRequestException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/InternalServerException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/NotFoundException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerError.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerInvalidDataException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerIoException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerServiceException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/PermissionDeniedException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/RateLimitException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnauthorizedException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnexpectedStatusCodeException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnprocessableEntityException.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/Handlers.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/HttpRequestBodies.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitServiceImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineService.kt create mode 100644 openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceImpl.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/TestServerExtension.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/client/OpenlayerClientTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/core/http/HttpRequestTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/core/http/RetryingHttpClientTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/core/http/SerializerTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/CommitTestResultListParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/CommitTestResultListResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineTestResultListParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineTestResultListResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectInferencePipelineListParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectInferencePipelineListResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/ErrorHandlingTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/ServiceParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/CommitServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/InferencePipelineServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/ProjectServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/commits/TestResultServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/CommitServiceTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceTest.kt create mode 100644 openlayer-java-lib/.keep create mode 100644 openlayer-java/build.gradle.kts create mode 100644 release-please-config.json create mode 100755 scripts/format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test create mode 100644 settings.gradle.kts diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..6c9d27e --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y \ + libxkbcommon0 \ + ca-certificates \ + ca-certificates-java \ + make \ + curl \ + git \ + openjdk-17-jdk \ + unzip \ + libc++1 \ + vim \ + && apt-get clean autoclean + +# Ensure UTF-8 encoding +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +WORKDIR /workspace + +COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..d55fc4d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..022b841 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5813609 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,36 @@ +name: CI +on: + push: + branches: + - main + pull_request: + branches: + - main + +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: + distribution: temurin + java-version: | + 8 + 17 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Run lints + run: ./scripts/lint + diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 0000000..7dd499b --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,39 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/openlayer-ai/openlayer-java/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: | + 8 + 17 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + 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 }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 0000000..c09f373 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,23 @@ +name: Release Doctor +on: + pull_request: + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'openlayer-ai/openlayer-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + 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/.gitignore b/.gitignore new file mode 100644 index 0000000..1c94d9f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.gradle +.idea +build +codegen.log +kls_database.db diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..c476280 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1-alpha.0" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 0000000..2b7dbf3 --- /dev/null +++ b/.stats.yml @@ -0,0 +1 @@ +configured_endpoints: 6 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8253082 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2024 Openlayer + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 7fdae21..1d8c59c 100644 --- a/README.md +++ b/README.md @@ -1 +1,252 @@ -# openlayer-java \ No newline at end of file +# Openlayer Java API Library + + + +[![Maven Central](https://img.shields.io/maven-central/v/org.openlayer/openlayer-java)](https://central.sonatype.com/artifact/org.openlayer/openlayer-java/0.0.1-alpha.0) + + + +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 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.stainlessapi.com/). + +## Documentation + +The REST API documentation can be found [on openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). + +--- + +## Getting started + +### Install dependencies + +#### Gradle + + + +```kotlin +implementation("org.openlayer:openlayer-java:0.0.1-alpha.0") +``` + +#### Maven + +```xml + + org.openlayer + openlayer-java + 0.0.1-alpha.0 + +``` + + + +### Configure the client + +Use `OpenlayerOkHttpClient.builder()` to configure the client. + +Alternately, set the environment with `OPENLAYER_API_KEY`, and use `OpenlayerOkHttpClient.fromEnv()` to read from the environment. + +```java +OpenlayerClient client = OpenlayerOkHttpClient.fromEnv(); + +// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties +OpenlayerClient client = OpenlayerOkHttpClient.builder() + .fromEnv() + // ... set properties on the builder + .build(); +``` + +| Property | Environment variable | Required | Default value | +| -------- | -------------------- | -------- | ------------- | +| apiKey | `OPENLAYER_API_KEY` | false | — | + +Read the documentation for more configuration options. + +--- + +### Example: creating a resource + +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. + +```java +import java.util.List; +import org.openlayer.models.InferencePipelineDataStreamParams; +import org.openlayer.models.InferencePipelineDataStreamResponse; + +InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.builder() + .rows(List.of(InferencePipelineDataStreamParams.Row.builder().build())) + .config(InferencePipelineDataStreamParams.Config.ofLlmData(InferencePipelineDataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .costColumnName("cost") + .inputVariableNames(List.of("user_query")) + .numOfTokenColumnName("tokens") + .timestampColumnName("timestamp") + .build())) + .build(); +InferencePipelineDataStreamResponse inferencePipelineDataStreamResponse = client.inferencePipelines().data().stream(params); +``` + +--- + +## Requests + +### Parameters and bodies + +To make a request to the Openlayer API, you generally build an instance of the appropriate `Params` class. + +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. + +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. + +```java +InferencePipelineDataStreamParams params = InferencePipelineDataStreamParams.builder() + // ... normal properties + .putAdditionalProperty("secret_param", "4242") + .build(); +``` + +## Responses + +### Response validation + +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. + +```java +InferencePipelineDataStreamResponse inferencePipelineDataStreamResponse = client.inferencePipelines().data().stream().validate(); +``` + +### 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. + +```java +JsonField field = responseObj._field(); + +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(); + + // 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); +} +``` + +### Additional model properties + +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: + +```java +JsonValue secret = inferencePipelineDataStreamResponse._additionalProperties().get("secret_field"); +``` + +--- + +--- + +## Error handling + +This library throws exceptions in a single hierarchy for easy handling: + +- **`OpenlayerException`** - Base exception for all exceptions + + - **`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. + + | 400 | BadRequestException | + | ------ | ----------------------------- | + | 401 | AuthenticationException | + | 403 | PermissionDeniedException | + | 404 | NotFoundException | + | 422 | UnprocessableEntityException | + | 429 | RateLimitException | + | 5xx | InternalServerException | + | others | UnexpectedStatusCodeException | + + - **`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) + +## Network options + +### Retries + +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: + +```java +OpenlayerClient client = OpenlayerOkHttpClient.builder() + .fromEnv() + .maxRetries(4) + .build(); +``` + +### Timeouts + +Requests time out after 1 minute by default. You can configure this on the client builder: + +```java +OpenlayerClient client = OpenlayerOkHttpClient.builder() + .fromEnv() + .timeout(Duration.ofSeconds(30)) + .build(); +``` + +### Proxies + +Requests can be routed through a proxy. You can configure this on the client builder: + +```java +OpenlayerClient client = OpenlayerOkHttpClient.builder() + .fromEnv() + .proxy(new Proxy( + Type.HTTP, + new InetSocketAddress("proxy.com", 8080) + )) + .build(); +``` + +## Making custom/undocumented requests + +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. + +### Undocumented request params + +To make requests using undocumented parameters, you can provide or override parameters on the params object +while building it. + +```kotlin +FooCreateParams address = FooCreateParams.builder() + .id("my_id") + .putAdditionalProperty("secret_prop", JsonValue.from("hello")) + .build(); +``` + +### Undocumented response properties + +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. + +## 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)_. +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. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..6dfa13e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,27 @@ +# Security Policy + +## 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. + +To report a security issue, please contact the Stainless team at security@stainlessapi.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Openlayer please follow the respective company's security reporting guidelines. + +### Openlayer Terms and Policies + +Please contact support@openlayer.com for any questions or concerns regarding security of our services. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 0000000..6fcdea6 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +warnings=() +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + warnings+=("The OPENLAYER_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + warnings+=("The OPENLAYER_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_KEY}" ]; then + warnings+=("The OPENLAYER_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_PASSWORD}" ]; then + warnings+=("The OPENLAYER_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenWarnings=${#warnings[@]} + +if [[ lenWarnings -gt 0 ]]; then + echo -e "Found the following warnings in the release environment:\n" + + for warning in "${warnings[@]}"; do + echo -e "- $warning\n" + done +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..bbd2896 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,20 @@ +plugins { + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" +} + +allprojects { + group = "org.openlayer" + version = "0.0.1-alpha.0" // x-release-please-version +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + + username.set(System.getenv("SONATYPE_USERNAME")) + password.set(System.getenv("SONATYPE_PASSWORD")) + } + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..b88cd06 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + `kotlin-dsl` +} + +repositories { + gradlePluginPortal() +} + +dependencies { + implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23") +} diff --git a/buildSrc/src/main/kotlin/openlayer.java.gradle.kts b/buildSrc/src/main/kotlin/openlayer.java.gradle.kts new file mode 100644 index 0000000..bc01a1d --- /dev/null +++ b/buildSrc/src/main/kotlin/openlayer.java.gradle.kts @@ -0,0 +1,57 @@ +import com.diffplug.gradle.spotless.SpotlessExtension +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import java.util.Locale + +plugins { + `java-library` + id("com.diffplug.spotless") +} + +repositories { + mavenCentral() +} + +configure { + withJavadocJar() + withSourcesJar() +} + +configure { + java { + importOrder() + removeUnusedImports() + palantirJavaFormat() + } +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } +} + +tasks.withType().configureEach { + options.compilerArgs.add("-Werror") + options.release.set(8) +} + +tasks.named("javadocJar") { + setZip64(true) +} + +tasks.named("jar") { + manifest { + attributes(mapOf( + "Implementation-Title" to project.name, + "Implementation-Version" to project.version + )) + } +} + +tasks.named("test") { + useJUnitPlatform() + + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} diff --git a/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts b/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts new file mode 100644 index 0000000..d5a6d5d --- /dev/null +++ b/buildSrc/src/main/kotlin/openlayer.kotlin.gradle.kts @@ -0,0 +1,27 @@ +import com.diffplug.gradle.spotless.SpotlessExtension +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("openlayer.java") + kotlin("jvm") +} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } +} + +configure { + kotlin { + ktfmt().kotlinlangStyle() + } +} + +tasks.withType().configureEach { + kotlinOptions { + allWarningsAsErrors = true + freeCompilerArgs = listOf("-Xjvm-default=all", "-Xjdk-release=1.8") + jvmTarget = "1.8" + } +} diff --git a/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts b/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts new file mode 100644 index 0000000..1179c4d --- /dev/null +++ b/buildSrc/src/main/kotlin/openlayer.publish.gradle.kts @@ -0,0 +1,67 @@ +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 + +plugins { + `maven-publish` + `signing` +} + +configure { + publications { + register("maven") { + from(components["java"]) + + pom { + name.set("Openlayer API") + description.set("API for interacting with the Openlayer server.") + url.set("https://openlayer.com/docs/api-reference/rest/overview") + + licenses { + license { + name.set("Apache-2.0") + } + } + + developers { + developer { + name.set("Openlayer") + email.set("support@openlayer.com") + } + } + + scm { + connection.set("scm:git:git://github.com/openlayer-ai/openlayer-java.git") + developerConnection.set("scm:git:git://github.com/openlayer-ai/openlayer-java.git") + url.set("https://github.com/openlayer-ai/openlayer-java") + } + + versionMapping { + allVariants { + fromResolutionResult() + } + } + } + } + } +} + +signing { + val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null } + val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null } + val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null } + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys( + signingKeyId, + signingKey, + signingPassword, + ) + sign(publishing.publications["maven"]) + } +} + +tasks.named("publish") { + dependsOn(":closeAndReleaseSonatypeStagingRepository") +} diff --git a/examples/.keep b/examples/.keep new file mode 100644 index 0000000..d8c73e9 --- /dev/null +++ b/examples/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store example files demonstrating usage of this SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..a3bc58f --- /dev/null +++ b/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.caching=true +org.gradle.jvmargs=-Xmx4g +org.gradle.parallel=true +kotlin.daemon.jvmargs=-Xmx4g diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..e6441136f3d4ba8a0da8d277868979cfbc8ad796 GIT binary patch literal 43453 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 yu?e%!_ptzGB|8GrCfu%p?(_ zQccdaaVK$5bz;*rnyK{_SQYM>;aES6Qs^lj9lEs6_J+%nIiuQC*fN;z8md>r_~Mfl zU%p5Dt_YT>gQqfr@`cR!$NWr~+`CZb%dn;WtzrAOI>P_JtsB76PYe*<%H(y>qx-`Kq!X_; z<{RpAqYhE=L1r*M)gNF3B8r(<%8mo*SR2hu zccLRZwGARt)Hlo1euqTyM>^!HK*!Q2P;4UYrysje@;(<|$&%vQekbn|0Ruu_Io(w4#%p6ld2Yp7tlA`Y$cciThP zKzNGIMPXX%&Ud0uQh!uQZz|FB`4KGD?3!ND?wQt6!n*f4EmCoJUh&b?;B{|lxs#F- z31~HQ`SF4x$&v00@(P+j1pAaj5!s`)b2RDBp*PB=2IB>oBF!*6vwr7Dp%zpAx*dPr zb@Zjq^XjN?O4QcZ*O+8>)|HlrR>oD*?WQl5ri3R#2?*W6iJ>>kH%KnnME&TT@ZzrHS$Q%LC?n|e>V+D+8D zYc4)QddFz7I8#}y#Wj6>4P%34dZH~OUDb?uP%-E zwjXM(?Sg~1!|wI(RVuxbu)-rH+O=igSho_pDCw(c6b=P zKk4ATlB?bj9+HHlh<_!&z0rx13K3ZrAR8W)!@Y}o`?a*JJsD+twZIv`W)@Y?Amu_u zz``@-e2X}27$i(2=9rvIu5uTUOVhzwu%mNazS|lZb&PT;XE2|B&W1>=B58#*!~D&) zfVmJGg8UdP*fx(>Cj^?yS^zH#o-$Q-*$SnK(ZVFkw+er=>N^7!)FtP3y~Xxnu^nzY zikgB>Nj0%;WOltWIob|}%lo?_C7<``a5hEkx&1ku$|)i>Rh6@3h*`slY=9U}(Ql_< zaNG*J8vb&@zpdhAvv`?{=zDedJ23TD&Zg__snRAH4eh~^oawdYi6A3w8<Ozh@Kw)#bdktM^GVb zrG08?0bG?|NG+w^&JvD*7LAbjED{_Zkc`3H!My>0u5Q}m!+6VokMLXxl`Mkd=g&Xx z-a>m*#G3SLlhbKB!)tnzfWOBV;u;ftU}S!NdD5+YtOjLg?X}dl>7m^gOpihrf1;PY zvll&>dIuUGs{Qnd- zwIR3oIrct8Va^Tm0t#(bJD7c$Z7DO9*7NnRZorrSm`b`cxz>OIC;jSE3DO8`hX955ui`s%||YQtt2 z5DNA&pG-V+4oI2s*x^>-$6J?p=I>C|9wZF8z;VjR??Icg?1w2v5Me+FgAeGGa8(3S z4vg*$>zC-WIVZtJ7}o9{D-7d>zCe|z#<9>CFve-OPAYsneTb^JH!Enaza#j}^mXy1 z+ULn^10+rWLF6j2>Ya@@Kq?26>AqK{A_| zQKb*~F1>sE*=d?A?W7N2j?L09_7n+HGi{VY;MoTGr_)G9)ot$p!-UY5zZ2Xtbm=t z@dpPSGwgH=QtIcEulQNI>S-#ifbnO5EWkI;$A|pxJd885oM+ zGZ0_0gDvG8q2xebj+fbCHYfAXuZStH2j~|d^sBAzo46(K8n59+T6rzBwK)^rfPT+B zyIFw)9YC-V^rhtK`!3jrhmW-sTmM+tPH+;nwjL#-SjQPUZ53L@A>y*rt(#M(qsiB2 zx6B)dI}6Wlsw%bJ8h|(lhkJVogQZA&n{?Vgs6gNSXzuZpEyu*xySy8ro07QZ7Vk1!3tJphN_5V7qOiyK8p z#@jcDD8nmtYi1^l8ml;AF<#IPK?!pqf9D4moYk>d99Im}Jtwj6c#+A;f)CQ*f-hZ< z=p_T86jog%!p)D&5g9taSwYi&eP z#JuEK%+NULWus;0w32-SYFku#i}d~+{Pkho&^{;RxzP&0!RCm3-9K6`>KZpnzS6?L z^H^V*s!8<>x8bomvD%rh>Zp3>Db%kyin;qtl+jAv8Oo~1g~mqGAC&Qi_wy|xEt2iz zWAJEfTV%cl2Cs<1L&DLRVVH05EDq`pH7Oh7sR`NNkL%wi}8n>IXcO40hp+J+sC!W?!krJf!GJNE8uj zg-y~Ns-<~D?yqbzVRB}G>0A^f0!^N7l=$m0OdZuqAOQqLc zX?AEGr1Ht+inZ-Qiwnl@Z0qukd__a!C*CKuGdy5#nD7VUBM^6OCpxCa2A(X;e0&V4 zM&WR8+wErQ7UIc6LY~Q9x%Sn*Tn>>P`^t&idaOEnOd(Ufw#>NoR^1QdhJ8s`h^|R_ zXX`c5*O~Xdvh%q;7L!_!ohf$NfEBmCde|#uVZvEo>OfEq%+Ns7&_f$OR9xsihRpBb z+cjk8LyDm@U{YN>+r46?nn{7Gh(;WhFw6GAxtcKD+YWV?uge>;+q#Xx4!GpRkVZYu zzsF}1)7$?%s9g9CH=Zs+B%M_)+~*j3L0&Q9u7!|+T`^O{xE6qvAP?XWv9_MrZKdo& z%IyU)$Q95AB4!#hT!_dA>4e@zjOBD*Y=XjtMm)V|+IXzjuM;(l+8aA5#Kaz_$rR6! zj>#&^DidYD$nUY(D$mH`9eb|dtV0b{S>H6FBfq>t5`;OxA4Nn{J(+XihF(stSche7$es&~N$epi&PDM_N`As;*9D^L==2Q7Z2zD+CiU(|+-kL*VG+&9!Yb3LgPy?A zm7Z&^qRG_JIxK7-FBzZI3Q<;{`DIxtc48k> zc|0dmX;Z=W$+)qE)~`yn6MdoJ4co;%!`ddy+FV538Y)j(vg}5*k(WK)KWZ3WaOG!8 z!syGn=s{H$odtpqFrT#JGM*utN7B((abXnpDM6w56nhw}OY}0TiTG1#f*VFZr+^-g zbP10`$LPq_;PvrA1XXlyx2uM^mrjTzX}w{yuLo-cOClE8MMk47T25G8M!9Z5ypOSV zAJUBGEg5L2fY)ZGJb^E34R2zJ?}Vf>{~gB!8=5Z) z9y$>5c)=;o0HeHHSuE4U)#vG&KF|I%-cF6f$~pdYJWk_dD}iOA>iA$O$+4%@>JU08 zS`ep)$XLPJ+n0_i@PkF#ri6T8?ZeAot$6JIYHm&P6EB=BiaNY|aA$W0I+nz*zkz_z zkEru!tj!QUffq%)8y0y`T&`fuus-1p>=^hnBiBqD^hXrPs`PY9tU3m0np~rISY09> z`P3s=-kt_cYcxWd{de@}TwSqg*xVhp;E9zCsnXo6z z?f&Sv^U7n4`xr=mXle94HzOdN!2kB~4=%)u&N!+2;z6UYKUDqi-s6AZ!haB;@&B`? z_TRX0%@suz^TRdCb?!vNJYPY8L_}&07uySH9%W^Tc&1pia6y1q#?*Drf}GjGbPjBS zbOPcUY#*$3sL2x4v_i*Y=N7E$mR}J%|GUI(>WEr+28+V z%v5{#e!UF*6~G&%;l*q*$V?&r$Pp^sE^i-0$+RH3ERUUdQ0>rAq2(2QAbG}$y{de( z>{qD~GGuOk559Y@%$?N^1ApVL_a704>8OD%8Y%8B;FCt%AoPu8*D1 zLB5X>b}Syz81pn;xnB}%0FnwazlWfUV)Z-~rZg6~b z6!9J$EcE&sEbzcy?CI~=boWA&eeIa%z(7SE^qgVLz??1Vbc1*aRvc%Mri)AJaAG!p z$X!_9Ds;Zz)f+;%s&dRcJt2==P{^j3bf0M=nJd&xwUGlUFn?H=2W(*2I2Gdu zv!gYCwM10aeus)`RIZSrCK=&oKaO_Ry~D1B5!y0R=%!i2*KfXGYX&gNv_u+n9wiR5 z*e$Zjju&ODRW3phN925%S(jL+bCHv6rZtc?!*`1TyYXT6%Ju=|X;6D@lq$8T zW{Y|e39ioPez(pBH%k)HzFITXHvnD6hw^lIoUMA;qAJ^CU?top1fo@s7xT13Fvn1H z6JWa-6+FJF#x>~+A;D~;VDs26>^oH0EI`IYT2iagy23?nyJ==i{g4%HrAf1-*v zK1)~@&(KkwR7TL}L(A@C_S0G;-GMDy=MJn2$FP5s<%wC)4jC5PXoxrQBFZ_k0P{{s@sz+gX`-!=T8rcB(=7vW}^K6oLWMmp(rwDh}b zwaGGd>yEy6fHv%jM$yJXo5oMAQ>c9j`**}F?MCry;T@47@r?&sKHgVe$MCqk#Z_3S z1GZI~nOEN*P~+UaFGnj{{Jo@16`(qVNtbU>O0Hf57-P>x8Jikp=`s8xWs^dAJ9lCQ z)GFm+=OV%AMVqVATtN@|vp61VVAHRn87}%PC^RAzJ%JngmZTasWBAWsoAqBU+8L8u z4A&Pe?fmTm0?mK-BL9t+{y7o(7jm+RpOhL9KnY#E&qu^}B6=K_dB}*VlSEiC9fn)+V=J;OnN)Ta5v66ic1rG+dGAJ1 z1%Zb_+!$=tQ~lxQrzv3x#CPb?CekEkA}0MYSgx$Jdd}q8+R=ma$|&1a#)TQ=l$1tQ z=tL9&_^vJ)Pk}EDO-va`UCT1m#Uty1{v^A3P~83_#v^ozH}6*9mIjIr;t3Uv%@VeW zGL6(CwCUp)Jq%G0bIG%?{_*Y#5IHf*5M@wPo6A{$Um++Co$wLC=J1aoG93&T7Ho}P z=mGEPP7GbvoG!uD$k(H3A$Z))+i{Hy?QHdk>3xSBXR0j!11O^mEe9RHmw!pvzv?Ua~2_l2Yh~_!s1qS`|0~0)YsbHSz8!mG)WiJE| z2f($6TQtt6L_f~ApQYQKSb=`053LgrQq7G@98#igV>y#i==-nEjQ!XNu9 z~;mE+gtj4IDDNQJ~JVk5Ux6&LCSFL!y=>79kE9=V}J7tD==Ga+IW zX)r7>VZ9dY=V&}DR))xUoV!u(Z|%3ciQi_2jl}3=$Agc(`RPb z8kEBpvY>1FGQ9W$n>Cq=DIpski};nE)`p3IUw1Oz0|wxll^)4dq3;CCY@RyJgFgc# zKouFh!`?Xuo{IMz^xi-h=StCis_M7yq$u) z?XHvw*HP0VgR+KR6wI)jEMX|ssqYvSf*_3W8zVTQzD?3>H!#>InzpSO)@SC8q*ii- z%%h}_#0{4JG;Jm`4zg};BPTGkYamx$Xo#O~lBirRY)q=5M45n{GCfV7h9qwyu1NxOMoP4)jjZMxmT|IQQh0U7C$EbnMN<3)Kk?fFHYq$d|ICu>KbY_hO zTZM+uKHe(cIZfEqyzyYSUBZa8;Fcut-GN!HSA9ius`ltNebF46ZX_BbZNU}}ZOm{M2&nANL9@0qvih15(|`S~z}m&h!u4x~(%MAO$jHRWNfuxWF#B)E&g3ghSQ9|> z(MFaLQj)NE0lowyjvg8z0#m6FIuKE9lDO~Glg}nSb7`~^&#(Lw{}GVOS>U)m8bF}x zVjbXljBm34Cs-yM6TVusr+3kYFjr28STT3g056y3cH5Tmge~ASxBj z%|yb>$eF;WgrcOZf569sDZOVwoo%8>XO>XQOX1OyN9I-SQgrm;U;+#3OI(zrWyow3 zk==|{lt2xrQ%FIXOTejR>;wv(Pb8u8}BUpx?yd(Abh6? zsoO3VYWkeLnF43&@*#MQ9-i-d0t*xN-UEyNKeyNMHw|A(k(_6QKO=nKMCxD(W(Yop zsRQ)QeL4X3Lxp^L%wzi2-WVSsf61dqliPUM7srDB?Wm6Lzn0&{*}|IsKQW;02(Y&| zaTKv|`U(pSzuvR6Rduu$wzK_W-Y-7>7s?G$)U}&uK;<>vU}^^ns@Z!p+9?St1s)dG zK%y6xkPyyS1$~&6v{kl?Md6gwM|>mt6Upm>oa8RLD^8T{0?HC!Z>;(Bob7el(DV6x zi`I)$&E&ngwFS@bi4^xFLAn`=fzTC;aimE^!cMI2n@Vo%Ae-ne`RF((&5y6xsjjAZ zVguVoQ?Z9uk$2ON;ersE%PU*xGO@T*;j1BO5#TuZKEf(mB7|g7pcEA=nYJ{s3vlbg zd4-DUlD{*6o%Gc^N!Nptgay>j6E5;3psI+C3Q!1ZIbeCubW%w4pq9)MSDyB{HLm|k zxv-{$$A*pS@csolri$Ge<4VZ}e~78JOL-EVyrbxKra^d{?|NnPp86!q>t<&IP07?Z z^>~IK^k#OEKgRH+LjllZXk7iA>2cfH6+(e&9ku5poo~6y{GC5>(bRK7hwjiurqAiZ zg*DmtgY}v83IjE&AbiWgMyFbaRUPZ{lYiz$U^&Zt2YjG<%m((&_JUbZcfJ22(>bi5 z!J?<7AySj0JZ&<-qXX;mcV!f~>G=sB0KnjWca4}vrtunD^1TrpfeS^4dvFr!65knK zZh`d;*VOkPs4*-9kL>$GP0`(M!j~B;#x?Ba~&s6CopvO86oM?-? zOw#dIRc;6A6T?B`Qp%^<U5 z19x(ywSH$_N+Io!6;e?`tWaM$`=Db!gzx|lQ${DG!zb1Zl&|{kX0y6xvO1o z220r<-oaS^^R2pEyY;=Qllqpmue|5yI~D|iI!IGt@iod{Opz@*ml^w2bNs)p`M(Io z|E;;m*Xpjd9l)4G#KaWfV(t8YUn@A;nK^#xgv=LtnArX|vWQVuw3}B${h+frU2>9^ z!l6)!Uo4`5k`<<;E(ido7M6lKTgWezNLq>U*=uz&s=cc$1%>VrAeOoUtA|T6gO4>UNqsdK=NF*8|~*sl&wI=x9-EGiq*aqV!(VVXA57 zw9*o6Ir8Lj1npUXvlevtn(_+^X5rzdR>#(}4YcB9O50q97%rW2me5_L=%ffYPUSRc z!vv?Kv>dH994Qi>U(a<0KF6NH5b16enCp+mw^Hb3Xs1^tThFpz!3QuN#}KBbww`(h z7GO)1olDqy6?T$()R7y%NYx*B0k_2IBiZ14&8|JPFxeMF{vSTxF-Vi3+ZOI=Thq2} zyQgjYY1_7^ZQHh{?P))4+qUiQJLi1&{yE>h?~jU%tjdV0h|FENbM3X(KnJdPKc?~k zh=^Ixv*+smUll!DTWH!jrV*wSh*(mx0o6}1@JExzF(#9FXgmTXVoU+>kDe68N)dkQ zH#_98Zv$}lQwjKL@yBd;U(UD0UCl322=pav<=6g>03{O_3oKTq;9bLFX1ia*lw;#K zOiYDcBJf)82->83N_Y(J7Kr_3lE)hAu;)Q(nUVydv+l+nQ$?|%MWTy`t>{havFSQloHwiIkGK9YZ79^9?AZo0ZyQlVR#}lF%dn5n%xYksXf8gnBm=wO7g_^! zauQ-bH1Dc@3ItZ-9D_*pH}p!IG7j8A_o94#~>$LR|TFq zZ-b00*nuw|-5C2lJDCw&8p5N~Z1J&TrcyErds&!l3$eSz%`(*izc;-?HAFD9AHb-| z>)id`QCrzRws^9(#&=pIx9OEf2rmlob8sK&xPCWS+nD~qzU|qG6KwA{zbikcfQrdH z+ zQg>O<`K4L8rN7`GJB0*3<3`z({lWe#K!4AZLsI{%z#ja^OpfjU{!{)x0ZH~RB0W5X zTwN^w=|nA!4PEU2=LR05x~}|B&ZP?#pNgDMwD*ajI6oJqv!L81gu=KpqH22avXf0w zX3HjbCI!n9>l046)5rr5&v5ja!xkKK42zmqHzPx$9Nn_MZk`gLeSLgC=LFf;H1O#B zn=8|^1iRrujHfbgA+8i<9jaXc;CQBAmQvMGQPhFec2H1knCK2x!T`e6soyrqCamX% zTQ4dX_E*8so)E*TB$*io{$c6X)~{aWfaqdTh=xEeGvOAN9H&-t5tEE-qso<+C!2>+ zskX51H-H}#X{A75wqFe-J{?o8Bx|>fTBtl&tcbdR|132Ztqu5X0i-pisB-z8n71%q%>EF}yy5?z=Ve`}hVh{Drv1YWL zW=%ug_&chF11gDv3D6B)Tz5g54H0mDHNjuKZ+)CKFk4Z|$RD zfRuKLW`1B>B?*RUfVd0+u8h3r-{@fZ{k)c!93t1b0+Q9vOaRnEn1*IL>5Z4E4dZ!7 ztp4GP-^1d>8~LMeb}bW!(aAnB1tM_*la=Xx)q(I0Y@__Zd$!KYb8T2VBRw%e$iSdZ zkwdMwd}eV9q*;YvrBFTv1>1+}{H!JK2M*C|TNe$ZSA>UHKk);wz$(F$rXVc|sI^lD zV^?_J!3cLM;GJuBMbftbaRUs$;F}HDEDtIeHQ)^EJJ1F9FKJTGH<(Jj`phE6OuvE) zqK^K`;3S{Y#1M@8yRQwH`?kHMq4tHX#rJ>5lY3DM#o@or4&^_xtBC(|JpGTfrbGkA z2Tu+AyT^pHannww!4^!$5?@5v`LYy~T`qs7SYt$JgrY(w%C+IWA;ZkwEF)u5sDvOK zGk;G>Mh&elvXDcV69J_h02l&O;!{$({fng9Rlc3ID#tmB^FIG^w{HLUpF+iB`|
NnX)EH+Nua)3Y(c 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 '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# 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 + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/openlayer-java-client-okhttp/build.gradle.kts b/openlayer-java-client-okhttp/build.gradle.kts new file mode 100644 index 0000000..2788dd9 --- /dev/null +++ b/openlayer-java-client-okhttp/build.gradle.kts @@ -0,0 +1,15 @@ +plugins { + id("openlayer.kotlin") + id("openlayer.publish") +} + +dependencies { + api(project(":openlayer-java-core")) + + implementation("com.google.guava:guava:33.0.0-jre") + implementation("com.squareup.okhttp3:okhttp:4.12.0") + + testImplementation(kotlin("test")) + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.slf4j:slf4j-simple:2.0.12") +} diff --git a/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OkHttpClient.kt b/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OkHttpClient.kt new file mode 100644 index 0000000..bfa04c9 --- /dev/null +++ b/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OkHttpClient.kt @@ -0,0 +1,202 @@ +package org.openlayer.client.okhttp + +import com.google.common.collect.ListMultimap +import com.google.common.collect.MultimapBuilder +import java.io.IOException +import java.io.InputStream +import java.net.Proxy +import java.time.Duration +import java.util.concurrent.CompletableFuture +import okhttp3.Call +import okhttp3.Callback +import okhttp3.Headers +import okhttp3.HttpUrl +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.Response +import okio.BufferedSink +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpClient +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpRequestBody +import org.openlayer.core.http.HttpResponse +import org.openlayer.errors.OpenlayerIoException + +class OkHttpClient +private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : + HttpClient { + + private fun getClient(requestOptions: RequestOptions): okhttp3.OkHttpClient { + val timeout = requestOptions.timeout ?: return okHttpClient + return okHttpClient + .newBuilder() + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .build() + } + + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + val call = getClient(requestOptions).newCall(request.toRequest()) + + return try { + call.execute().toResponse() + } catch (e: IOException) { + throw OpenlayerIoException("Request failed", e) + } finally { + request.body?.close() + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + + 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()) + } + + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(OpenlayerIoException("Request failed", e)) + } + } + ) + + return future + } + + override fun close() { + okHttpClient.dispatcher.executorService.shutdown() + okHttpClient.connectionPool.evictAll() + okHttpClient.cache?.close() + } + + private fun HttpRequest.toRequest(): 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)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.forEach(builder::header) + + return builder.build() + } + + private fun HttpRequest.toUrl(): String { + url?.let { + return it + } + + val builder = baseUrl.newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.forEach(builder::addQueryParameter) + + return builder.toString() + } + + private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? { + return mediaType + } + + override fun contentLength(): Long { + return length + } + + override fun isOneShot(): Boolean { + return !repeatable() + } + + override fun writeTo(sink: BufferedSink) { + writeTo(sink.outputStream()) + } + } + } + + private fun Response.toResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int { + return code + } + + override fun headers(): ListMultimap { + return headers + } + + override fun body(): InputStream { + return body!!.byteStream() + } + + override fun close() { + body!!.close() + } + } + } + + private fun Headers.toHeaders(): ListMultimap { + val headers = + MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER) + .arrayListValues() + .build() + + forEach { pair -> headers.put(pair.first, pair.second) } + + return headers + } + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var baseUrl: HttpUrl? = null + // default timeout is 1 minute + private var timeout: Duration = Duration.ofSeconds(60) + private var proxy: Proxy? = null + + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } + + fun timeout(timeout: Duration) = apply { this.timeout = timeout } + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + fun build(): OkHttpClient { + return OkHttpClient( + okhttp3.OkHttpClient.Builder() + .connectTimeout(timeout) + .readTimeout(timeout) + .writeTimeout(timeout) + .callTimeout(if (timeout.seconds == 0L) timeout else timeout.plusSeconds(30)) + .proxy(proxy) + .build(), + checkNotNull(baseUrl) { "`baseUrl` is required but was not set" }, + ) + } + } +} diff --git a/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClient.kt b/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClient.kt new file mode 100644 index 0000000..ad640c1 --- /dev/null +++ b/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClient.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import org.openlayer.client.OpenlayerClient +import org.openlayer.client.OpenlayerClientImpl +import org.openlayer.core.ClientOptions + +class OpenlayerOkHttpClient private constructor() { + + companion object { + + @JvmStatic fun builder() = Builder() + + @JvmStatic fun fromEnv(): OpenlayerClient = builder().fromEnv().build() + } + + class Builder { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var baseUrl: String = ClientOptions.PRODUCTION_URL + // default timeout for client is 1 minute + private var timeout: Duration = Duration.ofSeconds(60) + private var proxy: Proxy? = null + + fun baseUrl(baseUrl: String) = apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + + fun timeout(timeout: Duration) = apply { this.timeout = timeout } + + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + + fun fromEnv() = apply { clientOptions.fromEnv() } + + fun build(): OpenlayerClient { + return OpenlayerClientImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build() + ) + .build() + ) + } + } +} diff --git a/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClientAsync.kt b/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClientAsync.kt new file mode 100644 index 0000000..1a33a1c --- /dev/null +++ b/openlayer-java-client-okhttp/src/main/kotlin/org/openlayer/client/okhttp/OpenlayerOkHttpClientAsync.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.client.okhttp + +import com.fasterxml.jackson.databind.json.JsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import org.openlayer.client.OpenlayerClientAsync +import org.openlayer.client.OpenlayerClientAsyncImpl +import org.openlayer.core.ClientOptions + +class OpenlayerOkHttpClientAsync private constructor() { + + companion object { + + @JvmStatic fun builder() = Builder() + + @JvmStatic fun fromEnv(): OpenlayerClientAsync = builder().fromEnv().build() + } + + class Builder { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var baseUrl: String = ClientOptions.PRODUCTION_URL + // default timeout for client is 1 minute + private var timeout: Duration = Duration.ofSeconds(60) + private var proxy: Proxy? = null + + fun baseUrl(baseUrl: String) = apply { + clientOptions.baseUrl(baseUrl) + this.baseUrl = baseUrl + } + + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) } + + fun timeout(timeout: Duration) = apply { this.timeout = timeout } + + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun proxy(proxy: Proxy) = apply { this.proxy = proxy } + + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } + + fun fromEnv() = apply { clientOptions.fromEnv() } + + fun build(): OpenlayerClientAsync { + return OpenlayerClientAsyncImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .baseUrl(baseUrl) + .timeout(timeout) + .proxy(proxy) + .build() + ) + .build() + ) + } + } +} diff --git a/openlayer-java-core/build.gradle.kts b/openlayer-java-core/build.gradle.kts new file mode 100644 index 0000000..20066b7 --- /dev/null +++ b/openlayer-java-core/build.gradle.kts @@ -0,0 +1,26 @@ +plugins { + id("openlayer.kotlin") + id("openlayer.publish") +} + +dependencies { + api("com.fasterxml.jackson.core:jackson-core:2.14.3") + api("com.fasterxml.jackson.core:jackson-databind:2.14.3") + api("com.google.guava:guava:33.0.0-jre") + + implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.3") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.3") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.3") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.3") + implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") + implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") + + testImplementation(kotlin("test")) + testImplementation(project(":openlayer-java-client-okhttp")) + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-guava:3.25.3") + testImplementation("org.slf4j:slf4j-simple:2.0.12") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClient.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClient.kt new file mode 100644 index 0000000..916c328 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClient.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.client + +import org.openlayer.models.* +import org.openlayer.services.blocking.* + +interface OpenlayerClient { + + fun async(): OpenlayerClientAsync + + fun projects(): ProjectService + + fun commits(): CommitService + + fun inferencePipelines(): InferencePipelineService +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsync.kt new file mode 100644 index 0000000..38f2d7e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsync.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.client + +import org.openlayer.models.* +import org.openlayer.services.async.* + +interface OpenlayerClientAsync { + + fun sync(): OpenlayerClient + + fun projects(): ProjectServiceAsync + + fun commits(): CommitServiceAsync + + fun inferencePipelines(): InferencePipelineServiceAsync +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsyncImpl.kt new file mode 100644 index 0000000..2b4bbce --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientAsyncImpl.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.client + +import org.openlayer.core.ClientOptions +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.* +import org.openlayer.services.async.* +import org.openlayer.services.errorHandler + +class OpenlayerClientAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : OpenlayerClientAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val sync: OpenlayerClient by lazy { OpenlayerClientImpl(clientOptions) } + + private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptions) } + + private val commits: CommitServiceAsync by lazy { CommitServiceAsyncImpl(clientOptions) } + + private val inferencePipelines: InferencePipelineServiceAsync by lazy { + InferencePipelineServiceAsyncImpl(clientOptions) + } + + override fun sync(): OpenlayerClient = sync + + override fun projects(): ProjectServiceAsync = projects + + override fun commits(): CommitServiceAsync = commits + + override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientImpl.kt new file mode 100644 index 0000000..7f1a32e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/client/OpenlayerClientImpl.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.client + +import org.openlayer.core.ClientOptions +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.* +import org.openlayer.services.blocking.* +import org.openlayer.services.errorHandler + +class OpenlayerClientImpl +constructor( + private val clientOptions: ClientOptions, +) : OpenlayerClient { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val async: OpenlayerClientAsync by lazy { OpenlayerClientAsyncImpl(clientOptions) } + + private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptions) } + + private val commits: CommitService by lazy { CommitServiceImpl(clientOptions) } + + private val inferencePipelines: InferencePipelineService by lazy { + InferencePipelineServiceImpl(clientOptions) + } + + override fun async(): OpenlayerClientAsync = async + + override fun projects(): ProjectService = projects + + override fun commits(): CommitService = commits + + override fun inferencePipelines(): InferencePipelineService = inferencePipelines +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseDeserializer.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseDeserializer.kt new file mode 100644 index 0000000..e2344e5 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseDeserializer.kt @@ -0,0 +1,59 @@ +package org.openlayer.core + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +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 +import kotlin.reflect.KClass + +abstract class BaseDeserializer(type: KClass) : + StdDeserializer(type.java), ContextualDeserializer { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty? + ): JsonDeserializer { + return this + } + + override fun deserialize(parser: JsonParser, context: DeserializationContext): T { + return parser.codec.deserialize(parser.readValueAsTree()) + } + + 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) { + 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) { + null + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseSerializer.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseSerializer.kt new file mode 100644 index 0000000..d3031ef --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/BaseSerializer.kt @@ -0,0 +1,6 @@ +package org.openlayer.core + +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import kotlin.reflect.KClass + +abstract class BaseSerializer(type: KClass) : StdSerializer(type.java) diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/ClientOptions.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/ClientOptions.kt new file mode 100644 index 0000000..d3434c8 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/ClientOptions.kt @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.core + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap +import java.time.Clock +import org.openlayer.core.http.HttpClient +import org.openlayer.core.http.RetryingHttpClient + +class ClientOptions +private constructor( + @get:JvmName("httpClient") val httpClient: HttpClient, + @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + @get:JvmName("clock") val clock: Clock, + @get:JvmName("baseUrl") val baseUrl: String, + @get:JvmName("apiKey") val apiKey: String?, + @get:JvmName("headers") val headers: ListMultimap, + @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("responseValidation") val responseValidation: Boolean, +) { + + companion object { + + const val PRODUCTION_URL = "https://api.openlayer.com/v1" + + @JvmStatic fun builder() = Builder() + + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + } + + class Builder { + + private var httpClient: HttpClient? = null + private var jsonMapper: JsonMapper? = null + private var clock: Clock = Clock.systemUTC() + private var baseUrl: String = PRODUCTION_URL + private var headers: MutableMap> = mutableMapOf() + private var queryParams: MutableMap> = mutableMapOf() + private var responseValidation: Boolean = false + private var maxRetries: Int = 2 + private var apiKey: String? = null + + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + + fun clock(clock: Clock) = apply { this.clock = clock } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { + this.headers.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.headers.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(headers: Map>) = apply { + headers.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.headers.put(name, mutableListOf()) } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.queryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.queryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + queryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { this.queryParams.put(name, mutableListOf()) } + + 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 build(): ClientOptions { + checkNotNull(httpClient) { "`httpClient` is required but was not set" } + + val headers = ArrayListMultimap.create() + val queryParams = ArrayListMultimap.create() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + if (!apiKey.isNullOrEmpty()) { + headers.put("Authorization", "Bearer ${apiKey}") + } + this.headers.forEach(headers::replaceValues) + this.queryParams.forEach(queryParams::replaceValues) + + return ClientOptions( + RetryingHttpClient.builder() + .httpClient(httpClient!!) + .clock(clock) + .maxRetries(maxRetries) + .build(), + jsonMapper ?: jsonMapper(), + clock, + baseUrl, + apiKey, + headers.toUnmodifiable(), + queryParams.toUnmodifiable(), + responseValidation, + ) + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/ObjectMappers.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/ObjectMappers.kt new file mode 100644 index 0000000..5c86b9e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/ObjectMappers.kt @@ -0,0 +1,25 @@ +@file:JvmName("ObjectMappers") + +package org.openlayer.core + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.databind.DeserializationFeature +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.json.JsonMapper +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import com.fasterxml.jackson.module.kotlin.jacksonMapperBuilder + +fun jsonMapper(): JsonMapper = + jacksonMapperBuilder() + .addModule(Jdk8Module()) + .addModule(JavaTimeModule()) + .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) } + .build() diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/Properties.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/Properties.kt new file mode 100644 index 0000000..d057b2f --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/Properties.kt @@ -0,0 +1,47 @@ +@file:JvmName("Properties") + +package org.openlayer.core + +import java.util.Properties + +fun getOsArch(): String { + val osArch = System.getProperty("os.arch") + + return when (osArch) { + null -> "unknown" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" + "aarch64" -> "arm64" + else -> "other:${osArch}" + } +} + +fun getOsName(): String { + val osName = System.getProperty("os.name") + val vendorUrl = System.getProperty("java.vendor.url") + + return when { + osName == null -> "Unknown" + osName.startsWith("Linux") && vendorUrl == "http://www.android.com/" -> "Android" + osName.startsWith("Linux") -> "Linux" + osName.startsWith("Mac OS") -> "MacOS" + osName.startsWith("Windows") -> "Windows" + else -> "Other:${osName}" + } +} + +fun getOsVersion(): String { + return System.getProperty("os.version", "unknown") +} + +fun getPackageVersion(): String { + return Properties::class.java.`package`.implementationVersion ?: "unknown" +} + +fun getJavaVersion(): String { + return System.getProperty("java.version", "unknown") +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/RequestOptions.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/RequestOptions.kt new file mode 100644 index 0000000..2afeccc --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/RequestOptions.kt @@ -0,0 +1,40 @@ +package org.openlayer.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, + ) + } + + companion object { + + private val NONE = builder().build() + + @JvmStatic fun none() = NONE + + @JvmStatic fun builder() = Builder() + } + + class Builder { + private var responseValidation: Boolean? = null + private var timeout: Duration? = null + + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Duration) = apply { this.timeout = timeout } + + fun build(): RequestOptions { + return RequestOptions(responseValidation, timeout) + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/Utils.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/Utils.kt new file mode 100644 index 0000000..a7ca7ec --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/Utils.kt @@ -0,0 +1,61 @@ +@file:JvmName("Utils") + +package org.openlayer.core + +import com.google.common.collect.ImmutableListMultimap +import com.google.common.collect.ListMultimap +import com.google.common.collect.Multimaps +import java.util.Collections +import org.openlayer.errors.OpenlayerInvalidDataException + +@JvmSynthetic +internal fun T?.getOrThrow(name: String): T { + if (this == null) { + throw OpenlayerInvalidDataException("'${name}' is not present") + } + + return this +} + +@JvmSynthetic +internal fun List.toUnmodifiable(): List { + if (isEmpty()) { + return Collections.emptyList() + } + + return Collections.unmodifiableList(this) +} + +@JvmSynthetic +internal fun Map.toUnmodifiable(): Map { + if (isEmpty()) { + return Collections.emptyMap() + } + + return Collections.unmodifiableMap(this) +} + +@JvmSynthetic +internal fun ListMultimap.toUnmodifiable(): ListMultimap { + if (isEmpty()) { + return ImmutableListMultimap.of() + } + + return Multimaps.unmodifiableListMultimap(this) +} + +@JvmSynthetic +internal fun ListMultimap.getRequiredHeader(header: String): String { + val value = + entries() + .stream() + .filter { entry -> entry.key.equals(header, ignoreCase = true) } + .map { entry -> entry.value } + .findFirst() + if (!value.isPresent) { + throw OpenlayerInvalidDataException("Could not find $header header") + } + return value.get() +} + +internal interface Enum diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/Values.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/Values.kt new file mode 100644 index 0000000..b89c39b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/Values.kt @@ -0,0 +1,535 @@ +package org.openlayer.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 +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +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.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.databind.node.JsonNodeType.ARRAY +import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY +import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN +import com.fasterxml.jackson.databind.node.JsonNodeType.MISSING +import com.fasterxml.jackson.databind.node.JsonNodeType.NULL +import com.fasterxml.jackson.databind.node.JsonNodeType.NUMBER +import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT +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 java.nio.charset.Charset +import java.util.Objects +import java.util.Optional +import org.apache.hc.core5.http.ContentType +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(using = JsonField.Deserializer::class) +sealed class JsonField { + + fun isMissing(): Boolean = this is JsonMissing + + fun isNull(): Boolean = this is JsonNull + + fun asKnown(): Optional = + when (this) { + is KnownValue -> Optional.of(value) + else -> Optional.empty() + } + + /** + * 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`. + */ + fun asUnknown(): Optional = + when (this) { + is JsonValue -> Optional.of(this) + else -> Optional.empty() + } + + fun asBoolean(): Optional = + when (this) { + is JsonBoolean -> Optional.of(value) + else -> Optional.empty() + } + + fun asNumber(): Optional = + when (this) { + is JsonNumber -> Optional.of(value) + else -> Optional.empty() + } + + fun asString(): Optional = + when (this) { + is JsonString -> Optional.of(value) + else -> Optional.empty() + } + + fun asStringOrThrow(): String = + when (this) { + is JsonString -> value + else -> throw OpenlayerInvalidDataException("Value is not a string") + } + + fun asArray(): Optional> = + when (this) { + is JsonArray -> Optional.of(values) + else -> Optional.empty() + } + + fun asObject(): Optional> = + when (this) { + is JsonObject -> Optional.of(values) + else -> Optional.empty() + } + + @JvmSynthetic + 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}") + } + + @JvmSynthetic + internal fun getNullable(name: String): T? = + when (this) { + is KnownValue -> value + is JsonMissing -> null + is JsonNull -> null + else -> throw OpenlayerInvalidDataException("'${name}' is invalid, received ${this}") + } + + @JvmSynthetic + internal fun map(transform: (T) -> R): JsonField = + when (this) { + is KnownValue -> KnownValue.of(transform(value)) + is JsonValue -> this + } + + fun accept(visitor: Visitor): R = + when (this) { + is KnownValue -> visitor.visitKnown(value) + is JsonValue -> accept(visitor as JsonValue.Visitor) + } + + interface Visitor : JsonValue.Visitor { + fun visitKnown(value: T): R = visitDefault() + } + + companion object { + @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + + @JvmStatic + fun ofNullable(value: T?): JsonField = + when (value) { + null -> JsonNull.of() + else -> KnownValue.of(value) + } + } + + // 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 + } + + class Deserializer(private val type: JavaType? = null) : + BaseDeserializer>(JsonField::class) { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer> { + return Deserializer(context.contextualType?.containedType(0)) + } + + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> { + return type?.let { tryDeserialize(node, type) }?.let { of(it) } + ?: JsonValue.fromJsonNode(node) + } + + override fun getNullValue(context: DeserializationContext): JsonField<*> { + return JsonNull.of() + } + } +} + +@JsonDeserialize(using = JsonValue.Deserializer::class) +sealed class JsonValue : JsonField() { + + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + + fun accept(visitor: Visitor): R = + when (this) { + is JsonMissing -> visitor.visitMissing() + is JsonNull -> visitor.visitNull() + is JsonBoolean -> visitor.visitBoolean(value) + is JsonNumber -> visitor.visitNumber(value) + is JsonString -> visitor.visitString(value) + is JsonArray -> visitor.visitArray(values) + is JsonObject -> visitor.visitObject(values) + } + + interface Visitor { + fun visitNull(): R = visitDefault() + + fun visitMissing(): R = visitDefault() + + fun visitBoolean(value: Boolean): R = visitDefault() + + fun visitNumber(value: Number): R = visitDefault() + + fun visitString(value: String): R = visitDefault() + + fun visitArray(values: List): R = visitDefault() + + fun visitObject(values: Map): R = visitDefault() + + fun visitDefault(): R { + throw RuntimeException("Unexpected value") + } + } + + companion object { + + private val JSON_MAPPER = jsonMapper() + + @JvmStatic + fun from(value: Any?): JsonValue = + when (value) { + null -> JsonNull.of() + is JsonValue -> value + else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) + } + + @JvmStatic + fun fromJsonNode(node: JsonNode): JsonValue = + when (node.nodeType) { + MISSING -> JsonMissing.of() + NULL -> JsonNull.of() + BOOLEAN -> JsonBoolean.of(node.booleanValue()) + NUMBER -> JsonNumber.of(node.numberValue()) + STRING -> JsonString.of(node.textValue()) + ARRAY -> + JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> + JsonObject.of( + node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() + ) + BINARY, + POJO, + null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") + } + } + + class Deserializer : BaseDeserializer(JsonValue::class) { + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue { + return fromJsonNode(node) + } + + override fun getNullValue(context: DeserializationContext?): JsonValue { + return JsonNull.of() + } + } +} + +class KnownValue +private constructor( + @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T +) : JsonField() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KnownValue<*> && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) + } +} + +@JsonSerialize(using = JsonMissing.Serializer::class) +class JsonMissing : JsonValue() { + + override fun toString() = "" + + companion object { + private val INSTANCE: JsonMissing = JsonMissing() + + @JvmStatic fun of() = INSTANCE + } + + class Serializer : BaseSerializer(JsonMissing::class) { + override fun serialize( + value: JsonMissing, + generator: JsonGenerator, + provider: SerializerProvider + ) { + throw RuntimeException("JsonMissing cannot be serialized") + } + } +} + +@JsonSerialize(using = NullSerializer::class) +class JsonNull : JsonValue() { + + override fun toString() = "null" + + companion object { + private val INSTANCE: JsonNull = JsonNull() + + @JsonCreator @JvmStatic fun of() = INSTANCE + } +} + +class JsonBoolean +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonBoolean && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(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 + } + + return other is JsonNumber && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) + } +} + +class JsonString +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonString && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value + + companion object { + @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) + } +} + +class JsonArray +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: List +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonArray && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toUnmodifiable()) + } +} + +class JsonObject +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: Map +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonObject && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + @JsonCreator + @JvmStatic + fun of(values: Map) = JsonObject(values.toUnmodifiable()) + } +} + +@JacksonAnnotationsInside +@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 +) { + + 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 + + other as MultipartFormValue<*> + + if (name != other.name || contentType != other.contentType || filename != other.filename) + return false + + return when { + value is ByteArray && other.value is ByteArray -> value contentEquals other.value + else -> value?.equals(other.value) ?: (other.value == null) + } + } + + override fun toString(): String { + return "MultipartFormValue(name='$name', contentType=$contentType, filename=$filename, value=${valueToString()})" + } + + private fun valueToString(): String = + when (value) { + is ByteArray -> "ByteArray of size ${value.size}" + else -> value.toString() + } + + 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) + } +} + +internal object ContentTypes { + val DefaultText = ContentType.create(ContentType.TEXT_PLAIN.mimeType, Charset.forName("UTF-8")) + val DefaultBinary = ContentType.DEFAULT_BINARY +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/BinaryResponseContent.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/BinaryResponseContent.kt new file mode 100644 index 0000000..852939a --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/BinaryResponseContent.kt @@ -0,0 +1,15 @@ +package org.openlayer.core.http + +import java.io.Closeable +import java.io.IOException +import java.io.InputStream +import java.io.OutputStream + +interface BinaryResponseContent : Closeable { + + fun contentType(): String? + + fun body(): InputStream + + @Throws(IOException::class) fun writeTo(outputStream: OutputStream) +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpClient.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpClient.kt new file mode 100644 index 0000000..354581b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpClient.kt @@ -0,0 +1,18 @@ +package org.openlayer.core.http + +import java.io.Closeable +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions + +interface HttpClient : Closeable { + + fun execute( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpMethod.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpMethod.kt new file mode 100644 index 0000000..53afed9 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpMethod.kt @@ -0,0 +1,13 @@ +package org.openlayer.core.http + +enum class HttpMethod { + GET, + HEAD, + POST, + PUT, + DELETE, + CONNECT, + OPTIONS, + TRACE, + PATCH, +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequest.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequest.kt new file mode 100644 index 0000000..3f30a60 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequest.kt @@ -0,0 +1,92 @@ +package org.openlayer.core.http + +import com.google.common.collect.ArrayListMultimap +import com.google.common.collect.ListMultimap +import com.google.common.collect.Multimap +import com.google.common.collect.MultimapBuilder +import org.openlayer.core.toUnmodifiable + +class HttpRequest +private constructor( + @get:JvmName("method") val method: HttpMethod, + @get:JvmName("url") val url: String?, + @get:JvmName("pathSegments") val pathSegments: List, + @get:JvmName("queryParams") val queryParams: ListMultimap, + @get:JvmName("headers") val headers: ListMultimap, + @get:JvmName("body") val body: HttpRequestBody?, +) { + + override fun toString(): String = + "HttpRequest {method=$method, pathSegments=$pathSegments, queryParams=$queryParams, headers=$headers, body=$body}" + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var method: HttpMethod? = null + private var url: String? = null + private var pathSegments: MutableList = ArrayList() + private var queryParams: ListMultimap = ArrayListMultimap.create() + private var body: HttpRequestBody? = null + private var headers: ListMultimap = + MultimapBuilder.treeKeys(String.CASE_INSENSITIVE_ORDER).arrayListValues().build() + + fun method(method: HttpMethod) = apply { this.method = method } + + fun url(url: String) = apply { this.url = url } + + fun addPathSegment(pathSegment: String) = apply { this.pathSegments.add(pathSegment) } + + fun addPathSegments(vararg pathSegments: String) = apply { + for (pathSegment in pathSegments) { + this.pathSegments.add(pathSegment) + } + } + + fun putQueryParam(name: String, value: String) = apply { + this.queryParams.replaceValues(name, listOf(value)) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.queryParams.replaceValues(name, values) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + queryParams.forEach(this::putQueryParams) + } + + fun putAllQueryParams(queryParams: Multimap) = apply { + queryParams.asMap().forEach(this::putQueryParams) + } + + fun putHeader(name: String, value: String) = apply { + this.headers.replaceValues(name, listOf(value)) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.headers.replaceValues(name, values) + } + + fun putAllHeaders(headers: Map>) = apply { + headers.forEach(this::putHeaders) + } + + fun putAllHeaders(headers: Multimap) = apply { + headers.asMap().forEach(this::putHeaders) + } + + fun body(body: HttpRequestBody) = apply { this.body = body } + + fun build(): HttpRequest = + HttpRequest( + checkNotNull(method) { "`method` is required but was not set" }, + url, + pathSegments.toUnmodifiable(), + queryParams.toUnmodifiable(), + headers, + body, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequestBody.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequestBody.kt new file mode 100644 index 0000000..e85338d --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpRequestBody.kt @@ -0,0 +1,25 @@ +package org.openlayer.core.http + +import java.io.Closeable +import java.io.IOException +import java.io.OutputStream + +interface HttpRequestBody : Closeable { + + @Throws(IOException::class) fun writeTo(outputStream: OutputStream) + + fun contentType(): String? + + fun contentLength(): Long + + /** + * Determines if a request can be repeated in a meaningful way, for example before doing a + * retry. + * + * The most typical case when a request can't be retried is if the request body is being + * streamed. In this case the body data isn't available on subsequent attempts. + */ + fun repeatable(): Boolean + + override fun close() +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpResponse.kt new file mode 100644 index 0000000..8f50461 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/HttpResponse.kt @@ -0,0 +1,19 @@ +package org.openlayer.core.http + +import com.google.common.collect.ListMultimap +import java.io.Closeable +import java.io.InputStream + +interface HttpResponse : Closeable { + + fun statusCode(): Int + + fun headers(): ListMultimap + + fun body(): InputStream + + interface Handler { + + fun handle(response: HttpResponse): T + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/RetryingHttpClient.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/RetryingHttpClient.kt new file mode 100644 index 0000000..4f33c10 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/core/http/RetryingHttpClient.kt @@ -0,0 +1,246 @@ +@file:JvmSynthetic + +package org.openlayer.core.http + +import com.google.common.util.concurrent.MoreExecutors +import java.io.IOException +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.time.format.DateTimeParseException +import java.time.temporal.ChronoUnit +import java.util.Timer +import java.util.TimerTask +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ThreadLocalRandom +import java.util.concurrent.TimeUnit +import java.util.function.Function +import kotlin.math.min +import kotlin.math.pow +import org.openlayer.core.RequestOptions +import org.openlayer.errors.OpenlayerIoException + +class RetryingHttpClient +private constructor( + private val httpClient: HttpClient, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, +) : HttpClient { + + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.execute(request, requestOptions) + } + + maybeAddIdempotencyHeader(request) + + var retries = 0 + + while (true) { + val response = + try { + val response = httpClient.execute(request, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (t: Throwable) { + if (++retries > maxRetries || !shouldRetry(t)) { + throw t + } + + null + } + + val backoffMillis = getRetryBackoffMillis(retries, response) + Thread.sleep(backoffMillis.toMillis()) + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.executeAsync(request, requestOptions) + } + + maybeAddIdempotencyHeader(request) + + var retries = 0 + + fun wrap(future: CompletableFuture): CompletableFuture { + return future + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable? + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffMillis = getRetryBackoffMillis(retries, response) + return sleepAsync(backoffMillis.toMillis()).thenCompose { + wrap(httpClient.executeAsync(request, requestOptions)) + } + }, + MoreExecutors.directExecutor() + ) + .thenCompose(Function.identity()) + } + + return wrap(httpClient.executeAsync(request, requestOptions)) + } + + override fun close() { + httpClient.close() + } + + private fun isRetryable(request: HttpRequest): Boolean { + // Some requests, such as when a request body is being streamed, cannot be retried because + // the body data aren't available on subsequent attempts. + return request.body?.repeatable() ?: true + } + + private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" + + private fun maybeAddIdempotencyHeader(request: HttpRequest) { + if (idempotencyHeader != null && !request.headers.containsKey(idempotencyHeader)) { + // Set a header to uniquely identify the request when retried + request.headers.put(idempotencyHeader, idempotencyKey()) + } + } + + private fun shouldRetry(response: HttpResponse): Boolean { + // Note: this is not a standard header + val shouldRetryHeader = response.headers().get("x-should-retry").getOrNull(0) + val statusCode = response.statusCode() + + return when { + // If the server explicitly says whether to retry, obey + shouldRetryHeader == "true" -> true + shouldRetryHeader == "false" -> false + + // Retry on request timeouts + statusCode == 408 -> true + // Retry on lock timeouts + statusCode == 409 -> true + // Retry on rate limits + statusCode == 429 -> true + // Retry internal errors + statusCode >= 500 -> true + else -> false + } + } + + private fun shouldRetry(throwable: Throwable): Boolean { + // Only retry IOException and OpenlayerIoException, other exceptions are not intended to be + // retried. + return throwable is IOException || throwable is OpenlayerIoException + } + + private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { + // About the Retry-After header: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After + response + ?.headers() + ?.let { headers -> + headers + .get("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + ?: headers.get("Retry-After").getOrNull(0)?.let { retryAfter -> + retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME + ) + ) + } catch (e: DateTimeParseException) { + null + } + } + } + ?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable + // amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter + } + } + + // Apply exponential backoff, but not more than the max. + val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) + + // Apply some jitter + val jitter = 1.0 - 0.25 * ThreadLocalRandom.current().nextDouble() + + 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) + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var httpClient: HttpClient? = null + private var clock: Clock = Clock.systemUTC() + private var maxRetries: Int = 2 + private var idempotencyHeader: String? = null + + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + fun clock(clock: Clock) = apply { this.clock = clock } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } + + fun build(): HttpClient = + RetryingHttpClient( + checkNotNull(httpClient) { "`httpClient` is required but was not set" }, + clock, + maxRetries, + idempotencyHeader, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/BadRequestException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/BadRequestException.kt new file mode 100644 index 0000000..0e7c4a5 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/BadRequestException.kt @@ -0,0 +1,13 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class BadRequestException +constructor( + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = 400 + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/InternalServerException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/InternalServerException.kt new file mode 100644 index 0000000..fab7f30 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/InternalServerException.kt @@ -0,0 +1,14 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class InternalServerException +constructor( + private val statusCode: Int, + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = statusCode + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/NotFoundException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/NotFoundException.kt new file mode 100644 index 0000000..eaf39a8 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/NotFoundException.kt @@ -0,0 +1,13 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class NotFoundException +constructor( + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = 404 + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerError.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerError.kt new file mode 100644 index 0000000..0edb21a --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerError.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.errors + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import java.util.Objects +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable + +@JsonDeserialize(builder = OpenlayerError.Builder::class) +@NoAutoDetect +class OpenlayerError +constructor( + private val additionalProperties: Map, +) { + + @JsonAnyGetter fun additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OpenlayerError && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + return Objects.hash(additionalProperties) + } + + override fun toString() = "OpenlayerError{additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var additionalProperties: MutableMap = mutableMapOf() + + fun from(error: OpenlayerError) = apply { additionalProperties(error.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(): OpenlayerError = OpenlayerError(additionalProperties.toUnmodifiable()) + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerException.kt new file mode 100644 index 0000000..29dd500 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerException.kt @@ -0,0 +1,5 @@ +package org.openlayer.errors + +open class OpenlayerException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerInvalidDataException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerInvalidDataException.kt new file mode 100644 index 0000000..aaaaa7f --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerInvalidDataException.kt @@ -0,0 +1,5 @@ +package org.openlayer.errors + +class OpenlayerInvalidDataException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : OpenlayerException(message, cause) diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerIoException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerIoException.kt new file mode 100644 index 0000000..4cefedf --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerIoException.kt @@ -0,0 +1,5 @@ +package org.openlayer.errors + +class OpenlayerIoException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : OpenlayerException(message, cause) diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerServiceException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerServiceException.kt new file mode 100644 index 0000000..39024b5 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/OpenlayerServiceException.kt @@ -0,0 +1,15 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +abstract class OpenlayerServiceException +@JvmOverloads +constructor( + private val headers: ListMultimap, + message: String? = null, + cause: Throwable? = null +) : OpenlayerException(message, cause) { + abstract fun statusCode(): Int + + fun headers(): ListMultimap = headers +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/PermissionDeniedException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/PermissionDeniedException.kt new file mode 100644 index 0000000..88acfb1 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/PermissionDeniedException.kt @@ -0,0 +1,13 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class PermissionDeniedException +constructor( + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = 403 + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/RateLimitException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/RateLimitException.kt new file mode 100644 index 0000000..3abc49b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/RateLimitException.kt @@ -0,0 +1,13 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class RateLimitException +constructor( + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = 429 + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnauthorizedException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnauthorizedException.kt new file mode 100644 index 0000000..8e5ea1d --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnauthorizedException.kt @@ -0,0 +1,13 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class UnauthorizedException +constructor( + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = 401 + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnexpectedStatusCodeException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnexpectedStatusCodeException.kt new file mode 100644 index 0000000..083edeb --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnexpectedStatusCodeException.kt @@ -0,0 +1,14 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class UnexpectedStatusCodeException +constructor( + private val statusCode: Int, + headers: ListMultimap, + private val body: String +) : OpenlayerServiceException(headers, "Unexpected status code: ${statusCode}") { + override fun statusCode(): Int = statusCode + + fun body() = body +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnprocessableEntityException.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnprocessableEntityException.kt new file mode 100644 index 0000000..32c5117 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/errors/UnprocessableEntityException.kt @@ -0,0 +1,13 @@ +package org.openlayer.errors + +import com.google.common.collect.ListMultimap + +class UnprocessableEntityException +constructor( + headers: ListMultimap, + private val error: OpenlayerError, +) : OpenlayerServiceException(headers, "${error}") { + override fun statusCode(): Int = 422 + + fun error(): OpenlayerError = error +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListParams.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListParams.kt new file mode 100644 index 0000000..8f36b3d --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListParams.kt @@ -0,0 +1,377 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Objects +import java.util.Optional +import org.openlayer.core.Enum +import org.openlayer.core.JsonField +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException +import org.openlayer.models.* + +class CommitTestResultListParams +constructor( + private val id: String, + private val includeArchived: Boolean?, + private val page: Long?, + private val perPage: Long?, + private val status: Status?, + private val type: Type?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun id(): String = id + + 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) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.includeArchived?.let { params.put("includeArchived", listOf(it.toString())) } + this.page?.let { params.put("page", listOf(it.toString())) } + this.perPage?.let { params.put("perPage", listOf(it.toString())) } + this.status?.let { params.put("status", listOf(it.toString())) } + this.type?.let { params.put("type", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> id + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitTestResultListParams && + this.id == other.id && + this.includeArchived == other.includeArchived && + this.page == other.page && + this.perPage == other.perPage && + this.status == other.status && + this.type == other.type && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + id, + includeArchived, + page, + perPage, + status, + type, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "CommitTestResultListParams{id=$id, includeArchived=$includeArchived, page=$page, perPage=$perPage, status=$status, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var id: 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 additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitTestResultListParams: CommitTestResultListParams) = apply { + this.id = commitTestResultListParams.id + this.includeArchived = commitTestResultListParams.includeArchived + this.page = commitTestResultListParams.page + this.perPage = commitTestResultListParams.perPage + this.status = commitTestResultListParams.status + this.type = commitTestResultListParams.type + additionalQueryParams(commitTestResultListParams.additionalQueryParams) + additionalHeaders(commitTestResultListParams.additionalHeaders) + additionalBodyProperties(commitTestResultListParams.additionalBodyProperties) + } + + fun id(id: String) = apply { this.id = id } + + /** 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 additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): CommitTestResultListParams = + CommitTestResultListParams( + checkNotNull(id) { "`id` is required but was not set" }, + includeArchived, + page, + perPage, + status, + type, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PASSING = Status(JsonField.of("passing")) + + @JvmField val FAILING = Status(JsonField.of("failing")) + + @JvmField val SKIPPED = Status(JsonField.of("skipped")) + + @JvmField val ERROR = Status(JsonField.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() + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val INTEGRITY = Type(JsonField.of("integrity")) + + @JvmField val CONSISTENCY = Type(JsonField.of("consistency")) + + @JvmField val PERFORMANCE = Type(JsonField.of("performance")) + + @JvmField val FAIRNESS = Type(JsonField.of("fairness")) + + @JvmField val ROBUSTNESS = Type(JsonField.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() + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListResponse.kt new file mode 100644 index 0000000..04127f0 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/CommitTestResultListResponse.kt @@ -0,0 +1,1664 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import org.openlayer.core.BaseDeserializer +import org.openlayer.core.BaseSerializer +import org.openlayer.core.Enum +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.getOrThrow +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(builder = CommitTestResultListResponse.Builder::class) +@NoAutoDetect +class CommitTestResultListResponse +private constructor( + private val _meta: JsonField<_Meta>, + private val items: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun _meta(): _Meta = _meta.getRequired("_meta") + + fun items(): List = items.getRequired("items") + + @JsonProperty("_meta") @ExcludeMissing fun __meta() = _meta + + @JsonProperty("items") @ExcludeMissing fun _items() = items + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): CommitTestResultListResponse = apply { + if (!validated) { + _meta().validate() + items().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CommitTestResultListResponse && + this._meta == other._meta && + this.items == other.items && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + _meta, + items, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "CommitTestResultListResponse{_meta=$_meta, items=$items, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var _meta: JsonField<_Meta> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commitTestResultListResponse: CommitTestResultListResponse) = apply { + this._meta = commitTestResultListResponse._meta + this.items = commitTestResultListResponse.items + additionalProperties(commitTestResultListResponse.additionalProperties) + } + + fun _meta(_meta: _Meta) = _meta(JsonField.of(_meta)) + + @JsonProperty("_meta") + @ExcludeMissing + fun _meta(_meta: JsonField<_Meta>) = apply { this._meta = _meta } + + 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( + _meta, + items.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = _Meta.Builder::class) + @NoAutoDetect + class _Meta + private constructor( + private val page: JsonField, + private val perPage: JsonField, + private val totalItems: JsonField, + private val totalPages: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The current page. */ + fun page(): Long = page.getRequired("page") + + /** The number of items per page. */ + fun perPage(): Long = perPage.getRequired("perPage") + + /** The total number of items. */ + fun totalItems(): Long = totalItems.getRequired("totalItems") + + /** The total number of pages. */ + fun totalPages(): Long = totalPages.getRequired("totalPages") + + /** The current page. */ + @JsonProperty("page") @ExcludeMissing fun _page() = page + + /** The number of items per page. */ + @JsonProperty("perPage") @ExcludeMissing fun _perPage() = perPage + + /** The total number of items. */ + @JsonProperty("totalItems") @ExcludeMissing fun _totalItems() = totalItems + + /** The total number of pages. */ + @JsonProperty("totalPages") @ExcludeMissing fun _totalPages() = totalPages + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): _Meta = apply { + if (!validated) { + page() + perPage() + totalItems() + totalPages() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is _Meta && + this.page == other.page && + this.perPage == other.perPage && + this.totalItems == other.totalItems && + this.totalPages == other.totalPages && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + page, + perPage, + totalItems, + totalPages, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "_Meta{page=$page, perPage=$perPage, totalItems=$totalItems, totalPages=$totalPages, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var page: JsonField = JsonMissing.of() + private var perPage: JsonField = JsonMissing.of() + private var totalItems: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_meta: _Meta) = apply { + this.page = _meta.page + this.perPage = _meta.perPage + this.totalItems = _meta.totalItems + this.totalPages = _meta.totalPages + additionalProperties(_meta.additionalProperties) + } + + /** The current page. */ + fun page(page: Long) = page(JsonField.of(page)) + + /** The current page. */ + @JsonProperty("page") + @ExcludeMissing + fun page(page: JsonField) = apply { this.page = page } + + /** The number of items per page. */ + fun perPage(perPage: Long) = perPage(JsonField.of(perPage)) + + /** The number of items per page. */ + @JsonProperty("perPage") + @ExcludeMissing + fun perPage(perPage: JsonField) = apply { this.perPage = perPage } + + /** The total number of items. */ + fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) + + /** The total number of items. */ + @JsonProperty("totalItems") + @ExcludeMissing + fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } + + /** The total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** The total number of pages. */ + @JsonProperty("totalPages") + @ExcludeMissing + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + 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(): _Meta = + _Meta( + page, + perPage, + totalItems, + totalPages, + additionalProperties.toUnmodifiable(), + ) + } + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + this.id == other.id && + this.goal == other.goal && + this.goalId == other.goalId && + this.projectVersionId == other.projectVersionId && + this.inferencePipelineId == other.inferencePipelineId && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.dateDataStarts == other.dateDataStarts && + this.dateDataEnds == other.dateDataEnds && + this.status == other.status && + this.statusMessage == other.statusMessage && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + goal, + goalId, + projectVersionId, + inferencePipelineId, + dateCreated, + dateUpdated, + dateDataStarts, + dateDataEnds, + status, + statusMessage, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable(), + ) + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PASSING = Status(JsonField.of("passing")) + + @JvmField val FAILING = Status(JsonField.of("failing")) + + @JvmField val SKIPPED = Status(JsonField.of("skipped")) + + @JvmField val ERROR = Status(JsonField.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() + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Goal && + this.id == other.id && + this.number == other.number && + this.name == other.name && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.description == other.description && + this.evaluationWindow == other.evaluationWindow && + this.delayWindow == other.delayWindow && + this.type == other.type && + this.subtype == other.subtype && + this.creatorId == other.creatorId && + this.originProjectVersionId == other.originProjectVersionId && + this.thresholds == other.thresholds && + this.archived == other.archived && + this.dateArchived == other.dateArchived && + this.suggested == other.suggested && + this.commentCount == other.commentCount && + this.usesMlModel == other.usesMlModel && + this.usesValidationDataset == other.usesValidationDataset && + this.usesTrainingDataset == other.usesTrainingDataset && + this.usesReferenceDataset == other.usesReferenceDataset && + this.usesProductionData == other.usesProductionData && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + 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, + ) + } + return 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}" + + 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.toUnmodifiable() }, + archived, + dateArchived, + suggested, + commentCount, + usesMlModel, + usesValidationDataset, + usesTrainingDataset, + usesReferenceDataset, + usesProductionData, + additionalProperties.toUnmodifiable(), + ) + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Threshold && + this.measurement == other.measurement && + this.insightName == other.insightName && + this.insightParameters == other.insightParameters && + this.operator == other.operator && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + measurement, + insightName, + insightParameters, + operator, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Threshold{measurement=$measurement, insightName=$insightName, insightParameters=$insightParameters, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable() }, + operator, + value, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val double: Double? = null, + private val boolean: Boolean? = null, + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun double(): Optional = Optional.ofNullable(double) + + fun boolean(): Optional = Optional.ofNullable(boolean) + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isDouble(): Boolean = double != null + + fun isBoolean(): Boolean = boolean != null + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asDouble(): Double = double.getOrThrow("double") + + fun asBoolean(): Boolean = boolean.getOrThrow("boolean") + + 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 { + double != null -> visitor.visitDouble(double) + boolean != null -> visitor.visitBoolean(boolean) + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if ( + double == null && + boolean == null && + string == null && + strings == null + ) { + throw OpenlayerInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.double == other.double && + this.boolean == other.boolean && + this.string == other.string && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + double, + boolean, + string, + strings, + ) + } + + override fun toString(): String { + return when { + double != null -> "Value{double=$double}" + boolean != null -> "Value{boolean=$boolean}" + string != null -> "Value{string=$string}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic fun ofBoolean(boolean: Boolean) = Value(boolean = boolean) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitDouble(double: Double): T + + fun visitBoolean(boolean: 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(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(boolean = 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.double != null -> generator.writeObject(value.double) + value.boolean != null -> generator.writeObject(value.boolean) + 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") + } + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamParams.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamParams.kt new file mode 100644 index 0000000..759d243 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamParams.kt @@ -0,0 +1,2236 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.util.Objects +import java.util.Optional +import org.openlayer.core.BaseDeserializer +import org.openlayer.core.BaseSerializer +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.getOrThrow +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException +import org.openlayer.models.* + +class InferencePipelineDataStreamParams +constructor( + private val id: String, + private val config: Config, + private val rows: List, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun id(): String = id + + fun config(): Config = config + + fun rows(): List = rows + + @JvmSynthetic + internal fun getBody(): InferencePipelineDataStreamBody { + return InferencePipelineDataStreamBody( + config, + rows, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> id + else -> "" + } + } + + @JsonDeserialize(builder = InferencePipelineDataStreamBody.Builder::class) + @NoAutoDetect + class InferencePipelineDataStreamBody + internal constructor( + private val config: Config?, + private val rows: List?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** Configuration for the data stream. Depends on your **Openlayer project task type**. */ + @JsonProperty("config") fun config(): Config? = config + + /** A list of entries that represent rows of a csv file */ + @JsonProperty("rows") fun rows(): List? = rows + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineDataStreamBody && + this.config == other.config && + this.rows == other.rows && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + config, + rows, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InferencePipelineDataStreamBody{config=$config, rows=$rows, additionalProperties=$additionalProperties}" + + 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 entries that represent rows of a csv file */ + @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" }.toUnmodifiable(), + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineDataStreamParams && + this.id == other.id && + this.config == other.config && + this.rows == other.rows && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + id, + config, + rows, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "InferencePipelineDataStreamParams{id=$id, config=$config, rows=$rows, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var id: String? = null + private var config: Config? = null + private var rows: MutableList = mutableListOf() + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineDataStreamParams: InferencePipelineDataStreamParams) = + apply { + this.id = inferencePipelineDataStreamParams.id + this.config = inferencePipelineDataStreamParams.config + this.rows(inferencePipelineDataStreamParams.rows) + additionalQueryParams(inferencePipelineDataStreamParams.additionalQueryParams) + additionalHeaders(inferencePipelineDataStreamParams.additionalHeaders) + additionalBodyProperties(inferencePipelineDataStreamParams.additionalBodyProperties) + } + + fun id(id: String) = apply { this.id = id } + + /** 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 entries that represent rows of a csv file */ + fun rows(rows: List) = apply { + this.rows.clear() + this.rows.addAll(rows) + } + + /** A list of entries that represent rows of a csv file */ + fun addRow(row: Row) = apply { this.rows.add(row) } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): InferencePipelineDataStreamParams = + InferencePipelineDataStreamParams( + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(config) { "`config` is required but was not set" }, + checkNotNull(rows) { "`rows` is required but was not set" }.toUnmodifiable(), + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + @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 other is Config && + this.llmData == other.llmData && + this.tabularClassificationData == other.tabularClassificationData && + this.tabularRegressionData == other.tabularRegressionData && + this.textClassificationData == other.textClassificationData + } + + override fun hashCode(): Int { + return Objects.hash( + llmData, + tabularClassificationData, + tabularRegressionData, + textClassificationData, + ) + } + + override fun toString(): String { + return 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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LlmData && + this.numOfTokenColumnName == other.numOfTokenColumnName && + this.contextColumnName == other.contextColumnName && + this.costColumnName == other.costColumnName && + this.groundTruthColumnName == other.groundTruthColumnName && + this.inferenceIdColumnName == other.inferenceIdColumnName && + this.inputVariableNames == other.inputVariableNames && + this.latencyColumnName == other.latencyColumnName && + this.metadata == other.metadata && + this.outputColumnName == other.outputColumnName && + this.prompt == other.prompt && + this.questionColumnName == other.questionColumnName && + this.timestampColumnName == other.timestampColumnName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + numOfTokenColumnName, + contextColumnName, + costColumnName, + groundTruthColumnName, + inferenceIdColumnName, + inputVariableNames, + latencyColumnName, + metadata, + outputColumnName, + prompt, + questionColumnName, + timestampColumnName, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable() }, + latencyColumnName, + metadata, + outputColumnName, + prompt.map { it.toUnmodifiable() }, + questionColumnName, + timestampColumnName, + additionalProperties.toUnmodifiable(), + ) + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Prompt && + this.role == other.role && + this.content == other.content && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + role, + content, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Prompt{role=$role, content=$content, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable(), + ) + } + } + } + + @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 + + private var hashCode: Int = 0 + + /** + * Array with the names of all categorical features in the dataset. E.g. + * ["Gender", "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. + * ["Gender", "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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TabularClassificationData && + this.categoricalFeatureNames == other.categoricalFeatureNames && + this.classNames == other.classNames && + this.featureNames == other.featureNames && + this.inferenceIdColumnName == other.inferenceIdColumnName && + this.labelColumnName == other.labelColumnName && + this.latencyColumnName == other.latencyColumnName && + this.metadata == other.metadata && + this.predictionsColumnName == other.predictionsColumnName && + this.predictionScoresColumnName == other.predictionScoresColumnName && + this.timestampColumnName == other.timestampColumnName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + categoricalFeatureNames, + classNames, + featureNames, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + timestampColumnName, + additionalProperties, + ) + } + return 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}" + + 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. + * ["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 + } + + /** + * 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.toUnmodifiable() }, + classNames.map { it.toUnmodifiable() }, + featureNames.map { it.toUnmodifiable() }, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + timestampColumnName, + additionalProperties.toUnmodifiable(), + ) + } + } + + @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 + + private var hashCode: Int = 0 + + /** + * 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TabularRegressionData && + this.categoricalFeatureNames == other.categoricalFeatureNames && + this.featureNames == other.featureNames && + this.inferenceIdColumnName == other.inferenceIdColumnName && + this.latencyColumnName == other.latencyColumnName && + this.metadata == other.metadata && + this.predictionsColumnName == other.predictionsColumnName && + this.targetColumnName == other.targetColumnName && + this.timestampColumnName == other.timestampColumnName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + categoricalFeatureNames, + featureNames, + inferenceIdColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + targetColumnName, + timestampColumnName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "TabularRegressionData{categoricalFeatureNames=$categoricalFeatureNames, featureNames=$featureNames, inferenceIdColumnName=$inferenceIdColumnName, latencyColumnName=$latencyColumnName, metadata=$metadata, predictionsColumnName=$predictionsColumnName, targetColumnName=$targetColumnName, timestampColumnName=$timestampColumnName, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable() }, + featureNames.map { it.toUnmodifiable() }, + inferenceIdColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + targetColumnName, + timestampColumnName, + additionalProperties.toUnmodifiable(), + ) + } + } + + @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 + + private var hashCode: Int = 0 + + /** + * 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TextClassificationData && + this.classNames == other.classNames && + this.inferenceIdColumnName == other.inferenceIdColumnName && + this.labelColumnName == other.labelColumnName && + this.latencyColumnName == other.latencyColumnName && + this.metadata == other.metadata && + this.predictionsColumnName == other.predictionsColumnName && + this.predictionScoresColumnName == other.predictionScoresColumnName && + this.textColumnName == other.textColumnName && + this.timestampColumnName == other.timestampColumnName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + classNames, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + textColumnName, + timestampColumnName, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable() }, + inferenceIdColumnName, + labelColumnName, + latencyColumnName, + metadata, + predictionsColumnName, + predictionScoresColumnName, + textColumnName, + timestampColumnName, + additionalProperties.toUnmodifiable(), + ) + } + } + } + + @JsonDeserialize(builder = Row.Builder::class) + @NoAutoDetect + class Row + private constructor( + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Row && this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(additionalProperties) + } + return hashCode + } + + override fun toString() = "Row{additionalProperties=$additionalProperties}" + + 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.toUnmodifiable()) + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamResponse.kt new file mode 100644 index 0000000..3ecfc52 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineDataStreamResponse.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.util.Objects +import org.openlayer.core.Enum +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(builder = InferencePipelineDataStreamResponse.Builder::class) +@NoAutoDetect +class InferencePipelineDataStreamResponse +private constructor( + private val success: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineDataStreamResponse && + this.success == other.success && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(success, additionalProperties) + } + return hashCode + } + + override fun toString() = + "InferencePipelineDataStreamResponse{success=$success, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable()) + } + + class Success + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Success && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TRUE = Success(JsonField.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() + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListParams.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListParams.kt new file mode 100644 index 0000000..36afe62 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListParams.kt @@ -0,0 +1,379 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Objects +import java.util.Optional +import org.openlayer.core.Enum +import org.openlayer.core.JsonField +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException +import org.openlayer.models.* + +class InferencePipelineTestResultListParams +constructor( + private val id: String, + private val includeArchived: Boolean?, + private val page: Long?, + private val perPage: Long?, + private val status: Status?, + private val type: Type?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun id(): String = id + + 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) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.includeArchived?.let { params.put("includeArchived", listOf(it.toString())) } + this.page?.let { params.put("page", listOf(it.toString())) } + this.perPage?.let { params.put("perPage", listOf(it.toString())) } + this.status?.let { params.put("status", listOf(it.toString())) } + this.type?.let { params.put("type", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> id + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineTestResultListParams && + this.id == other.id && + this.includeArchived == other.includeArchived && + this.page == other.page && + this.perPage == other.perPage && + this.status == other.status && + this.type == other.type && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + id, + includeArchived, + page, + perPage, + status, + type, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "InferencePipelineTestResultListParams{id=$id, includeArchived=$includeArchived, page=$page, perPage=$perPage, status=$status, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var id: 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 additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + inferencePipelineTestResultListParams: InferencePipelineTestResultListParams + ) = apply { + this.id = inferencePipelineTestResultListParams.id + this.includeArchived = inferencePipelineTestResultListParams.includeArchived + this.page = inferencePipelineTestResultListParams.page + this.perPage = inferencePipelineTestResultListParams.perPage + this.status = inferencePipelineTestResultListParams.status + this.type = inferencePipelineTestResultListParams.type + additionalQueryParams(inferencePipelineTestResultListParams.additionalQueryParams) + additionalHeaders(inferencePipelineTestResultListParams.additionalHeaders) + additionalBodyProperties(inferencePipelineTestResultListParams.additionalBodyProperties) + } + + fun id(id: String) = apply { this.id = id } + + /** 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 additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): InferencePipelineTestResultListParams = + InferencePipelineTestResultListParams( + checkNotNull(id) { "`id` is required but was not set" }, + includeArchived, + page, + perPage, + status, + type, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PASSING = Status(JsonField.of("passing")) + + @JvmField val FAILING = Status(JsonField.of("failing")) + + @JvmField val SKIPPED = Status(JsonField.of("skipped")) + + @JvmField val ERROR = Status(JsonField.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() + } + + class Type + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val INTEGRITY = Type(JsonField.of("integrity")) + + @JvmField val CONSISTENCY = Type(JsonField.of("consistency")) + + @JvmField val PERFORMANCE = Type(JsonField.of("performance")) + + @JvmField val FAIRNESS = Type(JsonField.of("fairness")) + + @JvmField val ROBUSTNESS = Type(JsonField.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() + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListResponse.kt new file mode 100644 index 0000000..a11dfed --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/InferencePipelineTestResultListResponse.kt @@ -0,0 +1,1666 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import org.openlayer.core.BaseDeserializer +import org.openlayer.core.BaseSerializer +import org.openlayer.core.Enum +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.getOrThrow +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(builder = InferencePipelineTestResultListResponse.Builder::class) +@NoAutoDetect +class InferencePipelineTestResultListResponse +private constructor( + private val _meta: JsonField<_Meta>, + private val items: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun _meta(): _Meta = _meta.getRequired("_meta") + + fun items(): List = items.getRequired("items") + + @JsonProperty("_meta") @ExcludeMissing fun __meta() = _meta + + @JsonProperty("items") @ExcludeMissing fun _items() = items + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InferencePipelineTestResultListResponse = apply { + if (!validated) { + _meta().validate() + items().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineTestResultListResponse && + this._meta == other._meta && + this.items == other.items && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + _meta, + items, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InferencePipelineTestResultListResponse{_meta=$_meta, items=$items, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var _meta: JsonField<_Meta> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + inferencePipelineTestResultListResponse: InferencePipelineTestResultListResponse + ) = apply { + this._meta = inferencePipelineTestResultListResponse._meta + this.items = inferencePipelineTestResultListResponse.items + additionalProperties(inferencePipelineTestResultListResponse.additionalProperties) + } + + fun _meta(_meta: _Meta) = _meta(JsonField.of(_meta)) + + @JsonProperty("_meta") + @ExcludeMissing + fun _meta(_meta: JsonField<_Meta>) = apply { this._meta = _meta } + + 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( + _meta, + items.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = _Meta.Builder::class) + @NoAutoDetect + class _Meta + private constructor( + private val page: JsonField, + private val perPage: JsonField, + private val totalItems: JsonField, + private val totalPages: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The current page. */ + fun page(): Long = page.getRequired("page") + + /** The number of items per page. */ + fun perPage(): Long = perPage.getRequired("perPage") + + /** The total number of items. */ + fun totalItems(): Long = totalItems.getRequired("totalItems") + + /** The total number of pages. */ + fun totalPages(): Long = totalPages.getRequired("totalPages") + + /** The current page. */ + @JsonProperty("page") @ExcludeMissing fun _page() = page + + /** The number of items per page. */ + @JsonProperty("perPage") @ExcludeMissing fun _perPage() = perPage + + /** The total number of items. */ + @JsonProperty("totalItems") @ExcludeMissing fun _totalItems() = totalItems + + /** The total number of pages. */ + @JsonProperty("totalPages") @ExcludeMissing fun _totalPages() = totalPages + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): _Meta = apply { + if (!validated) { + page() + perPage() + totalItems() + totalPages() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is _Meta && + this.page == other.page && + this.perPage == other.perPage && + this.totalItems == other.totalItems && + this.totalPages == other.totalPages && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + page, + perPage, + totalItems, + totalPages, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "_Meta{page=$page, perPage=$perPage, totalItems=$totalItems, totalPages=$totalPages, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var page: JsonField = JsonMissing.of() + private var perPage: JsonField = JsonMissing.of() + private var totalItems: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_meta: _Meta) = apply { + this.page = _meta.page + this.perPage = _meta.perPage + this.totalItems = _meta.totalItems + this.totalPages = _meta.totalPages + additionalProperties(_meta.additionalProperties) + } + + /** The current page. */ + fun page(page: Long) = page(JsonField.of(page)) + + /** The current page. */ + @JsonProperty("page") + @ExcludeMissing + fun page(page: JsonField) = apply { this.page = page } + + /** The number of items per page. */ + fun perPage(perPage: Long) = perPage(JsonField.of(perPage)) + + /** The number of items per page. */ + @JsonProperty("perPage") + @ExcludeMissing + fun perPage(perPage: JsonField) = apply { this.perPage = perPage } + + /** The total number of items. */ + fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) + + /** The total number of items. */ + @JsonProperty("totalItems") + @ExcludeMissing + fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } + + /** The total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** The total number of pages. */ + @JsonProperty("totalPages") + @ExcludeMissing + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + 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(): _Meta = + _Meta( + page, + perPage, + totalItems, + totalPages, + additionalProperties.toUnmodifiable(), + ) + } + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + this.id == other.id && + this.goal == other.goal && + this.goalId == other.goalId && + this.projectVersionId == other.projectVersionId && + this.inferencePipelineId == other.inferencePipelineId && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.dateDataStarts == other.dateDataStarts && + this.dateDataEnds == other.dateDataEnds && + this.status == other.status && + this.statusMessage == other.statusMessage && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + goal, + goalId, + projectVersionId, + inferencePipelineId, + dateCreated, + dateUpdated, + dateDataStarts, + dateDataEnds, + status, + statusMessage, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable(), + ) + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PASSING = Status(JsonField.of("passing")) + + @JvmField val FAILING = Status(JsonField.of("failing")) + + @JvmField val SKIPPED = Status(JsonField.of("skipped")) + + @JvmField val ERROR = Status(JsonField.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() + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Goal && + this.id == other.id && + this.number == other.number && + this.name == other.name && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.description == other.description && + this.evaluationWindow == other.evaluationWindow && + this.delayWindow == other.delayWindow && + this.type == other.type && + this.subtype == other.subtype && + this.creatorId == other.creatorId && + this.originProjectVersionId == other.originProjectVersionId && + this.thresholds == other.thresholds && + this.archived == other.archived && + this.dateArchived == other.dateArchived && + this.suggested == other.suggested && + this.commentCount == other.commentCount && + this.usesMlModel == other.usesMlModel && + this.usesValidationDataset == other.usesValidationDataset && + this.usesTrainingDataset == other.usesTrainingDataset && + this.usesReferenceDataset == other.usesReferenceDataset && + this.usesProductionData == other.usesProductionData && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + 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, + ) + } + return 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}" + + 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.toUnmodifiable() }, + archived, + dateArchived, + suggested, + commentCount, + usesMlModel, + usesValidationDataset, + usesTrainingDataset, + usesReferenceDataset, + usesProductionData, + additionalProperties.toUnmodifiable(), + ) + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Threshold && + this.measurement == other.measurement && + this.insightName == other.insightName && + this.insightParameters == other.insightParameters && + this.operator == other.operator && + this.value == other.value && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + measurement, + insightName, + insightParameters, + operator, + value, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Threshold{measurement=$measurement, insightName=$insightName, insightParameters=$insightParameters, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable() }, + operator, + value, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val double: Double? = null, + private val boolean: Boolean? = null, + private val string: String? = null, + private val strings: List? = null, + private val _json: JsonValue? = null, + ) { + + private var validated: Boolean = false + + fun double(): Optional = Optional.ofNullable(double) + + fun boolean(): Optional = Optional.ofNullable(boolean) + + fun string(): Optional = Optional.ofNullable(string) + + fun strings(): Optional> = Optional.ofNullable(strings) + + fun isDouble(): Boolean = double != null + + fun isBoolean(): Boolean = boolean != null + + fun isString(): Boolean = string != null + + fun isStrings(): Boolean = strings != null + + fun asDouble(): Double = double.getOrThrow("double") + + fun asBoolean(): Boolean = boolean.getOrThrow("boolean") + + 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 { + double != null -> visitor.visitDouble(double) + boolean != null -> visitor.visitBoolean(boolean) + string != null -> visitor.visitString(string) + strings != null -> visitor.visitStrings(strings) + else -> visitor.unknown(_json) + } + } + + fun validate(): Value = apply { + if (!validated) { + if ( + double == null && + boolean == null && + string == null && + strings == null + ) { + throw OpenlayerInvalidDataException("Unknown Value: $_json") + } + validated = true + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && + this.double == other.double && + this.boolean == other.boolean && + this.string == other.string && + this.strings == other.strings + } + + override fun hashCode(): Int { + return Objects.hash( + double, + boolean, + string, + strings, + ) + } + + override fun toString(): String { + return when { + double != null -> "Value{double=$double}" + boolean != null -> "Value{boolean=$boolean}" + string != null -> "Value{string=$string}" + strings != null -> "Value{strings=$strings}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + } + + companion object { + + @JvmStatic fun ofDouble(double: Double) = Value(double = double) + + @JvmStatic fun ofBoolean(boolean: Boolean) = Value(boolean = boolean) + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofStrings(strings: List) = Value(strings = strings) + } + + interface Visitor { + + fun visitDouble(double: Double): T + + fun visitBoolean(boolean: 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(double = it, _json = json) + } + tryDeserialize(node, jacksonTypeRef())?.let { + return Value(boolean = 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.double != null -> generator.writeObject(value.double) + value.boolean != null -> generator.writeObject(value.boolean) + 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") + } + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListParams.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListParams.kt new file mode 100644 index 0000000..5b862ce --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListParams.kt @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import java.util.Objects +import java.util.Optional +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.models.* + +class ProjectCommitListParams +constructor( + private val id: String, + private val page: Long?, + private val perPage: Long?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun id(): String = id + + fun page(): Optional = Optional.ofNullable(page) + + fun perPage(): Optional = Optional.ofNullable(perPage) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.page?.let { params.put("page", listOf(it.toString())) } + this.perPage?.let { params.put("perPage", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> id + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectCommitListParams && + this.id == other.id && + this.page == other.page && + this.perPage == other.perPage && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + id, + page, + perPage, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ProjectCommitListParams{id=$id, page=$page, perPage=$perPage, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var id: String? = null + private var page: Long? = null + private var perPage: Long? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectCommitListParams: ProjectCommitListParams) = apply { + this.id = projectCommitListParams.id + this.page = projectCommitListParams.page + this.perPage = projectCommitListParams.perPage + additionalQueryParams(projectCommitListParams.additionalQueryParams) + additionalHeaders(projectCommitListParams.additionalHeaders) + additionalBodyProperties(projectCommitListParams.additionalBodyProperties) + } + + fun id(id: String) = apply { this.id = id } + + /** 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 additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectCommitListParams = + ProjectCommitListParams( + checkNotNull(id) { "`id` is required but was not set" }, + page, + perPage, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListResponse.kt new file mode 100644 index 0000000..e75be66 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectCommitListResponse.kt @@ -0,0 +1,1308 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import org.openlayer.core.Enum +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(builder = ProjectCommitListResponse.Builder::class) +@NoAutoDetect +class ProjectCommitListResponse +private constructor( + private val _meta: JsonField<_Meta>, + private val items: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun _meta(): _Meta = _meta.getRequired("_meta") + + fun items(): List = items.getRequired("items") + + @JsonProperty("_meta") @ExcludeMissing fun __meta() = _meta + + @JsonProperty("items") @ExcludeMissing fun _items() = items + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectCommitListResponse = apply { + if (!validated) { + _meta().validate() + items().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectCommitListResponse && + this._meta == other._meta && + this.items == other.items && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + _meta, + items, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ProjectCommitListResponse{_meta=$_meta, items=$items, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var _meta: JsonField<_Meta> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectCommitListResponse: ProjectCommitListResponse) = apply { + this._meta = projectCommitListResponse._meta + this.items = projectCommitListResponse.items + additionalProperties(projectCommitListResponse.additionalProperties) + } + + fun _meta(_meta: _Meta) = _meta(JsonField.of(_meta)) + + @JsonProperty("_meta") + @ExcludeMissing + fun _meta(_meta: JsonField<_Meta>) = apply { this._meta = _meta } + + 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( + _meta, + items.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = _Meta.Builder::class) + @NoAutoDetect + class _Meta + private constructor( + private val page: JsonField, + private val perPage: JsonField, + private val totalItems: JsonField, + private val totalPages: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The current page. */ + fun page(): Long = page.getRequired("page") + + /** The number of items per page. */ + fun perPage(): Long = perPage.getRequired("perPage") + + /** The total number of items. */ + fun totalItems(): Long = totalItems.getRequired("totalItems") + + /** The total number of pages. */ + fun totalPages(): Long = totalPages.getRequired("totalPages") + + /** The current page. */ + @JsonProperty("page") @ExcludeMissing fun _page() = page + + /** The number of items per page. */ + @JsonProperty("perPage") @ExcludeMissing fun _perPage() = perPage + + /** The total number of items. */ + @JsonProperty("totalItems") @ExcludeMissing fun _totalItems() = totalItems + + /** The total number of pages. */ + @JsonProperty("totalPages") @ExcludeMissing fun _totalPages() = totalPages + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): _Meta = apply { + if (!validated) { + page() + perPage() + totalItems() + totalPages() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is _Meta && + this.page == other.page && + this.perPage == other.perPage && + this.totalItems == other.totalItems && + this.totalPages == other.totalPages && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + page, + perPage, + totalItems, + totalPages, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "_Meta{page=$page, perPage=$perPage, totalItems=$totalItems, totalPages=$totalPages, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var page: JsonField = JsonMissing.of() + private var perPage: JsonField = JsonMissing.of() + private var totalItems: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_meta: _Meta) = apply { + this.page = _meta.page + this.perPage = _meta.perPage + this.totalItems = _meta.totalItems + this.totalPages = _meta.totalPages + additionalProperties(_meta.additionalProperties) + } + + /** The current page. */ + fun page(page: Long) = page(JsonField.of(page)) + + /** The current page. */ + @JsonProperty("page") + @ExcludeMissing + fun page(page: JsonField) = apply { this.page = page } + + /** The number of items per page. */ + fun perPage(perPage: Long) = perPage(JsonField.of(perPage)) + + /** The number of items per page. */ + @JsonProperty("perPage") + @ExcludeMissing + fun perPage(perPage: JsonField) = apply { this.perPage = perPage } + + /** The total number of items. */ + fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) + + /** The total number of items. */ + @JsonProperty("totalItems") + @ExcludeMissing + fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } + + /** The total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** The total number of pages. */ + @JsonProperty("totalPages") + @ExcludeMissing + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + 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(): _Meta = + _Meta( + page, + perPage, + totalItems, + totalPages, + additionalProperties.toUnmodifiable(), + ) + } + } + + @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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + this.id == other.id && + this.dateCreated == other.dateCreated && + this.status == other.status && + this.statusMessage == other.statusMessage && + this.projectId == other.projectId && + this.storageUri == other.storageUri && + this.commit == other.commit && + this.deploymentStatus == other.deploymentStatus && + this.mlModelId == other.mlModelId && + this.validationDatasetId == other.validationDatasetId && + this.trainingDatasetId == other.trainingDatasetId && + this.archived == other.archived && + this.dateArchived == other.dateArchived && + this.passingGoalCount == other.passingGoalCount && + this.failingGoalCount == other.failingGoalCount && + this.totalGoalCount == other.totalGoalCount && + this.links == other.links && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + dateCreated, + status, + statusMessage, + projectId, + storageUri, + commit, + deploymentStatus, + mlModelId, + validationDatasetId, + trainingDatasetId, + archived, + dateArchived, + passingGoalCount, + failingGoalCount, + totalGoalCount, + links, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable(), + ) + } + + /** 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 + + private var hashCode: Int = 0 + + /** 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Commit && + this.id == other.id && + this.authorId == other.authorId && + this.dateCreated == other.dateCreated && + this.fileSize == other.fileSize && + this.message == other.message && + this.mlModelId == other.mlModelId && + this.validationDatasetId == other.validationDatasetId && + this.trainingDatasetId == other.trainingDatasetId && + this.storageUri == other.storageUri && + this.gitCommitSha == other.gitCommitSha && + this.gitCommitRef == other.gitCommitRef && + this.gitCommitUrl == other.gitCommitUrl && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + authorId, + dateCreated, + fileSize, + message, + mlModelId, + validationDatasetId, + trainingDatasetId, + storageUri, + gitCommitSha, + gitCommitRef, + gitCommitUrl, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable(), + ) + } + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val QUEUED = Status(JsonField.of("queued")) + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PAUSED = Status(JsonField.of("paused")) + + @JvmField val FAILED = Status(JsonField.of("failed")) + + @JvmField val COMPLETED = Status(JsonField.of("completed")) + + @JvmField val UNKNOWN = Status(JsonField.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() + } + + @JsonDeserialize(builder = Links.Builder::class) + @NoAutoDetect + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Links && + this.app == other.app && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(app, additionalProperties) + } + return hashCode + } + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable()) + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListParams.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListParams.kt new file mode 100644 index 0000000..3b5c238 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import java.util.Objects +import java.util.Optional +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.models.* + +class ProjectInferencePipelineListParams +constructor( + private val id: String, + private val name: String?, + private val page: Long?, + private val perPage: Long?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun id(): String = id + + fun name(): Optional = Optional.ofNullable(name) + + fun page(): Optional = Optional.ofNullable(page) + + fun perPage(): Optional = Optional.ofNullable(perPage) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.name?.let { params.put("name", listOf(it.toString())) } + this.page?.let { params.put("page", listOf(it.toString())) } + this.perPage?.let { params.put("perPage", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> id + else -> "" + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectInferencePipelineListParams && + this.id == other.id && + this.name == other.name && + this.page == other.page && + this.perPage == other.perPage && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + id, + name, + page, + perPage, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ProjectInferencePipelineListParams{id=$id, name=$name, page=$page, perPage=$perPage, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var id: String? = null + private var name: String? = null + private var page: Long? = null + private var perPage: Long? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectInferencePipelineListParams: ProjectInferencePipelineListParams) = + apply { + this.id = projectInferencePipelineListParams.id + this.name = projectInferencePipelineListParams.name + this.page = projectInferencePipelineListParams.page + this.perPage = projectInferencePipelineListParams.perPage + additionalQueryParams(projectInferencePipelineListParams.additionalQueryParams) + additionalHeaders(projectInferencePipelineListParams.additionalHeaders) + additionalBodyProperties( + projectInferencePipelineListParams.additionalBodyProperties + ) + } + + fun id(id: String) = apply { this.id = id } + + /** 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 } + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long) = apply { this.perPage = perPage } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectInferencePipelineListParams = + ProjectInferencePipelineListParams( + checkNotNull(id) { "`id` is required but was not set" }, + name, + page, + perPage, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListResponse.kt new file mode 100644 index 0000000..7663bb5 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectInferencePipelineListResponse.kt @@ -0,0 +1,1017 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import org.openlayer.core.Enum +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(builder = ProjectInferencePipelineListResponse.Builder::class) +@NoAutoDetect +class ProjectInferencePipelineListResponse +private constructor( + private val _meta: JsonField<_Meta>, + private val items: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun _meta(): _Meta = _meta.getRequired("_meta") + + fun items(): List = items.getRequired("items") + + @JsonProperty("_meta") @ExcludeMissing fun __meta() = _meta + + @JsonProperty("items") @ExcludeMissing fun _items() = items + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectInferencePipelineListResponse = apply { + if (!validated) { + _meta().validate() + items().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectInferencePipelineListResponse && + this._meta == other._meta && + this.items == other.items && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + _meta, + items, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ProjectInferencePipelineListResponse{_meta=$_meta, items=$items, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var _meta: JsonField<_Meta> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + projectInferencePipelineListResponse: ProjectInferencePipelineListResponse + ) = apply { + this._meta = projectInferencePipelineListResponse._meta + this.items = projectInferencePipelineListResponse.items + additionalProperties(projectInferencePipelineListResponse.additionalProperties) + } + + fun _meta(_meta: _Meta) = _meta(JsonField.of(_meta)) + + @JsonProperty("_meta") + @ExcludeMissing + fun _meta(_meta: JsonField<_Meta>) = apply { this._meta = _meta } + + 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( + _meta, + items.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = _Meta.Builder::class) + @NoAutoDetect + class _Meta + private constructor( + private val page: JsonField, + private val perPage: JsonField, + private val totalItems: JsonField, + private val totalPages: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The current page. */ + fun page(): Long = page.getRequired("page") + + /** The number of items per page. */ + fun perPage(): Long = perPage.getRequired("perPage") + + /** The total number of items. */ + fun totalItems(): Long = totalItems.getRequired("totalItems") + + /** The total number of pages. */ + fun totalPages(): Long = totalPages.getRequired("totalPages") + + /** The current page. */ + @JsonProperty("page") @ExcludeMissing fun _page() = page + + /** The number of items per page. */ + @JsonProperty("perPage") @ExcludeMissing fun _perPage() = perPage + + /** The total number of items. */ + @JsonProperty("totalItems") @ExcludeMissing fun _totalItems() = totalItems + + /** The total number of pages. */ + @JsonProperty("totalPages") @ExcludeMissing fun _totalPages() = totalPages + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): _Meta = apply { + if (!validated) { + page() + perPage() + totalItems() + totalPages() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is _Meta && + this.page == other.page && + this.perPage == other.perPage && + this.totalItems == other.totalItems && + this.totalPages == other.totalPages && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + page, + perPage, + totalItems, + totalPages, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "_Meta{page=$page, perPage=$perPage, totalItems=$totalItems, totalPages=$totalPages, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var page: JsonField = JsonMissing.of() + private var perPage: JsonField = JsonMissing.of() + private var totalItems: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_meta: _Meta) = apply { + this.page = _meta.page + this.perPage = _meta.perPage + this.totalItems = _meta.totalItems + this.totalPages = _meta.totalPages + additionalProperties(_meta.additionalProperties) + } + + /** The current page. */ + fun page(page: Long) = page(JsonField.of(page)) + + /** The current page. */ + @JsonProperty("page") + @ExcludeMissing + fun page(page: JsonField) = apply { this.page = page } + + /** The number of items per page. */ + fun perPage(perPage: Long) = perPage(JsonField.of(perPage)) + + /** The number of items per page. */ + @JsonProperty("perPage") + @ExcludeMissing + fun perPage(perPage: JsonField) = apply { this.perPage = perPage } + + /** The total number of items. */ + fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) + + /** The total number of items. */ + @JsonProperty("totalItems") + @ExcludeMissing + fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } + + /** The total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** The total number of pages. */ + @JsonProperty("totalPages") + @ExcludeMissing + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + 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(): _Meta = + _Meta( + page, + perPage, + totalItems, + totalPages, + additionalProperties.toUnmodifiable(), + ) + } + } + + @JsonDeserialize(builder = Item.Builder::class) + @NoAutoDetect + class Item + private constructor( + private val id: JsonField, + private val projectId: 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 referenceDatasetUri: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val storageType: JsonField, + private val links: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The inference pipeline id. */ + fun id(): String = id.getRequired("id") + + /** The project id. */ + fun projectId(): String = projectId.getRequired("projectId") + + /** 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 reference dataset URI. */ + fun referenceDatasetUri(): Optional = + Optional.ofNullable(referenceDatasetUri.getNullable("referenceDatasetUri")) + + /** 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")) + + /** The storage type. */ + fun storageType(): Optional = + Optional.ofNullable(storageType.getNullable("storageType")) + + 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 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 reference dataset URI. */ + @JsonProperty("referenceDatasetUri") + @ExcludeMissing + fun _referenceDatasetUri() = referenceDatasetUri + + /** 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 + + /** The storage type. */ + @JsonProperty("storageType") @ExcludeMissing fun _storageType() = storageType + + @JsonProperty("links") @ExcludeMissing fun _links() = links + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Item = apply { + if (!validated) { + id() + projectId() + name() + dateCreated() + dateUpdated() + dateLastSampleReceived() + description() + dateLastEvaluated() + dateOfNextEvaluation() + passingGoalCount() + failingGoalCount() + totalGoalCount() + referenceDatasetUri() + status() + statusMessage() + storageType() + links().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + this.id == other.id && + this.projectId == other.projectId && + this.name == other.name && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.dateLastSampleReceived == other.dateLastSampleReceived && + this.description == other.description && + this.dateLastEvaluated == other.dateLastEvaluated && + this.dateOfNextEvaluation == other.dateOfNextEvaluation && + this.passingGoalCount == other.passingGoalCount && + this.failingGoalCount == other.failingGoalCount && + this.totalGoalCount == other.totalGoalCount && + this.referenceDatasetUri == other.referenceDatasetUri && + this.status == other.status && + this.statusMessage == other.statusMessage && + this.storageType == other.storageType && + this.links == other.links && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + projectId, + name, + dateCreated, + dateUpdated, + dateLastSampleReceived, + description, + dateLastEvaluated, + dateOfNextEvaluation, + passingGoalCount, + failingGoalCount, + totalGoalCount, + referenceDatasetUri, + status, + statusMessage, + storageType, + links, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Item{id=$id, projectId=$projectId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateLastSampleReceived=$dateLastSampleReceived, description=$description, dateLastEvaluated=$dateLastEvaluated, dateOfNextEvaluation=$dateOfNextEvaluation, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, referenceDatasetUri=$referenceDatasetUri, status=$status, statusMessage=$statusMessage, storageType=$storageType, links=$links, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var projectId: 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 referenceDatasetUri: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var statusMessage: JsonField = JsonMissing.of() + private var storageType: 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.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.referenceDatasetUri = item.referenceDatasetUri + this.status = item.status + this.statusMessage = item.statusMessage + this.storageType = item.storageType + 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 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 reference dataset URI. */ + fun referenceDatasetUri(referenceDatasetUri: String) = + referenceDatasetUri(JsonField.of(referenceDatasetUri)) + + /** The reference dataset URI. */ + @JsonProperty("referenceDatasetUri") + @ExcludeMissing + fun referenceDatasetUri(referenceDatasetUri: JsonField) = apply { + this.referenceDatasetUri = referenceDatasetUri + } + + /** 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 + } + + /** The storage type. */ + fun storageType(storageType: StorageType) = storageType(JsonField.of(storageType)) + + /** The storage type. */ + @JsonProperty("storageType") + @ExcludeMissing + fun storageType(storageType: JsonField) = apply { + this.storageType = storageType + } + + 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, + name, + dateCreated, + dateUpdated, + dateLastSampleReceived, + description, + dateLastEvaluated, + dateOfNextEvaluation, + passingGoalCount, + failingGoalCount, + totalGoalCount, + referenceDatasetUri, + status, + statusMessage, + storageType, + links, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Links.Builder::class) + @NoAutoDetect + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Links && + this.app == other.app && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(app, additionalProperties) + } + return hashCode + } + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable()) + } + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val QUEUED = Status(JsonField.of("queued")) + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PAUSED = Status(JsonField.of("paused")) + + @JvmField val FAILED = Status(JsonField.of("failed")) + + @JvmField val COMPLETED = Status(JsonField.of("completed")) + + @JvmField val UNKNOWN = Status(JsonField.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() + } + + class StorageType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StorageType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val LOCAL = StorageType(JsonField.of("local")) + + @JvmField val S3 = StorageType(JsonField.of("s3")) + + @JvmField val GCS = StorageType(JsonField.of("gcs")) + + @JvmField val AZURE = StorageType(JsonField.of("azure")) + + @JvmStatic fun of(value: String) = StorageType(JsonField.of(value)) + } + + enum class Known { + LOCAL, + S3, + GCS, + AZURE, + } + + enum class Value { + LOCAL, + S3, + GCS, + AZURE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + LOCAL -> Value.LOCAL + S3 -> Value.S3 + GCS -> Value.GCS + AZURE -> Value.AZURE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + LOCAL -> Known.LOCAL + S3 -> Known.S3 + GCS -> Known.GCS + AZURE -> Known.AZURE + else -> throw OpenlayerInvalidDataException("Unknown StorageType: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListParams.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListParams.kt new file mode 100644 index 0000000..ce56d43 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListParams.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Objects +import java.util.Optional +import org.openlayer.core.Enum +import org.openlayer.core.JsonField +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException +import org.openlayer.models.* + +class ProjectListParams +constructor( + private val name: String?, + private val page: Long?, + private val perPage: Long?, + private val taskType: TaskType?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun name(): Optional = Optional.ofNullable(name) + + fun page(): Optional = Optional.ofNullable(page) + + fun perPage(): Optional = Optional.ofNullable(perPage) + + fun taskType(): Optional = Optional.ofNullable(taskType) + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.name?.let { params.put("name", listOf(it.toString())) } + this.page?.let { params.put("page", listOf(it.toString())) } + this.perPage?.let { params.put("perPage", listOf(it.toString())) } + this.taskType?.let { params.put("taskType", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectListParams && + this.name == other.name && + this.page == other.page && + this.perPage == other.perPage && + this.taskType == other.taskType && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + name, + page, + perPage, + taskType, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "ProjectListParams{name=$name, page=$page, perPage=$perPage, taskType=$taskType, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var name: String? = null + private var page: Long? = null + private var perPage: Long? = null + private var taskType: TaskType? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectListParams: ProjectListParams) = apply { + this.name = projectListParams.name + this.page = projectListParams.page + this.perPage = projectListParams.perPage + this.taskType = projectListParams.taskType + additionalQueryParams(projectListParams.additionalQueryParams) + additionalHeaders(projectListParams.additionalHeaders) + additionalBodyProperties(projectListParams.additionalBodyProperties) + } + + /** Filter list of items by project 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 } + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long) = apply { this.perPage = perPage } + + /** Filter list of items by task type. */ + fun taskType(taskType: TaskType) = apply { this.taskType = taskType } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectListParams = + ProjectListParams( + name, + page, + perPage, + taskType, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + class TaskType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaskType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val LLM_BASE = TaskType(JsonField.of("llm-base")) + + @JvmField val TABULAR_CLASSIFICATION = TaskType(JsonField.of("tabular-classification")) + + @JvmField val TABULAR_REGRESSION = TaskType(JsonField.of("tabular-regression")) + + @JvmField val TEXT_CLASSIFICATION = TaskType(JsonField.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() + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListResponse.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListResponse.kt new file mode 100644 index 0000000..7b1bac6 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/models/ProjectListResponse.kt @@ -0,0 +1,1381 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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 java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional +import org.openlayer.core.Enum +import org.openlayer.core.ExcludeMissing +import org.openlayer.core.JsonField +import org.openlayer.core.JsonMissing +import org.openlayer.core.JsonValue +import org.openlayer.core.NoAutoDetect +import org.openlayer.core.toUnmodifiable +import org.openlayer.errors.OpenlayerInvalidDataException + +@JsonDeserialize(builder = ProjectListResponse.Builder::class) +@NoAutoDetect +class ProjectListResponse +private constructor( + private val _meta: JsonField<_Meta>, + private val items: JsonField>, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun _meta(): _Meta = _meta.getRequired("_meta") + + fun items(): List = items.getRequired("items") + + @JsonProperty("_meta") @ExcludeMissing fun __meta() = _meta + + @JsonProperty("items") @ExcludeMissing fun _items() = items + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectListResponse = apply { + if (!validated) { + _meta().validate() + items().forEach { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProjectListResponse && + this._meta == other._meta && + this.items == other.items && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + _meta, + items, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "ProjectListResponse{_meta=$_meta, items=$items, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var _meta: JsonField<_Meta> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectListResponse: ProjectListResponse) = apply { + this._meta = projectListResponse._meta + this.items = projectListResponse.items + additionalProperties(projectListResponse.additionalProperties) + } + + fun _meta(_meta: _Meta) = _meta(JsonField.of(_meta)) + + @JsonProperty("_meta") + @ExcludeMissing + fun _meta(_meta: JsonField<_Meta>) = apply { this._meta = _meta } + + 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( + _meta, + items.map { it.toUnmodifiable() }, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = _Meta.Builder::class) + @NoAutoDetect + class _Meta + private constructor( + private val page: JsonField, + private val perPage: JsonField, + private val totalItems: JsonField, + private val totalPages: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The current page. */ + fun page(): Long = page.getRequired("page") + + /** The number of items per page. */ + fun perPage(): Long = perPage.getRequired("perPage") + + /** The total number of items. */ + fun totalItems(): Long = totalItems.getRequired("totalItems") + + /** The total number of pages. */ + fun totalPages(): Long = totalPages.getRequired("totalPages") + + /** The current page. */ + @JsonProperty("page") @ExcludeMissing fun _page() = page + + /** The number of items per page. */ + @JsonProperty("perPage") @ExcludeMissing fun _perPage() = perPage + + /** The total number of items. */ + @JsonProperty("totalItems") @ExcludeMissing fun _totalItems() = totalItems + + /** The total number of pages. */ + @JsonProperty("totalPages") @ExcludeMissing fun _totalPages() = totalPages + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): _Meta = apply { + if (!validated) { + page() + perPage() + totalItems() + totalPages() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is _Meta && + this.page == other.page && + this.perPage == other.perPage && + this.totalItems == other.totalItems && + this.totalPages == other.totalPages && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + page, + perPage, + totalItems, + totalPages, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "_Meta{page=$page, perPage=$perPage, totalItems=$totalItems, totalPages=$totalPages, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var page: JsonField = JsonMissing.of() + private var perPage: JsonField = JsonMissing.of() + private var totalItems: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_meta: _Meta) = apply { + this.page = _meta.page + this.perPage = _meta.perPage + this.totalItems = _meta.totalItems + this.totalPages = _meta.totalPages + additionalProperties(_meta.additionalProperties) + } + + /** The current page. */ + fun page(page: Long) = page(JsonField.of(page)) + + /** The current page. */ + @JsonProperty("page") + @ExcludeMissing + fun page(page: JsonField) = apply { this.page = page } + + /** The number of items per page. */ + fun perPage(perPage: Long) = perPage(JsonField.of(perPage)) + + /** The number of items per page. */ + @JsonProperty("perPage") + @ExcludeMissing + fun perPage(perPage: JsonField) = apply { this.perPage = perPage } + + /** The total number of items. */ + fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) + + /** The total number of items. */ + @JsonProperty("totalItems") + @ExcludeMissing + fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } + + /** The total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** The total number of pages. */ + @JsonProperty("totalPages") + @ExcludeMissing + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + 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(): _Meta = + _Meta( + page, + perPage, + totalItems, + totalPages, + additionalProperties.toUnmodifiable(), + ) + } + } + + @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 sample: 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 unreadNotificationCount: JsonField, + private val links: JsonField, + private val slackChannelNotificationsEnabled: JsonField, + private val slackChannelName: JsonField, + private val slackChannelId: JsonField, + private val gitRepo: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** 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")) + + /** Whether the project is a sample project or a user-created project. */ + fun sample(): Boolean = sample.getRequired("sample") + + /** 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") + + /** The number of unread notifications in the project. */ + fun unreadNotificationCount(): Optional = + Optional.ofNullable(unreadNotificationCount.getNullable("unreadNotificationCount")) + + /** Links to the project. */ + fun links(): Links = links.getRequired("links") + + /** Whether slack channel notifications are enabled for the project. */ + fun slackChannelNotificationsEnabled(): Optional = + Optional.ofNullable( + slackChannelNotificationsEnabled.getNullable("slackChannelNotificationsEnabled") + ) + + /** The slack channel connected to the project. */ + fun slackChannelName(): Optional = + Optional.ofNullable(slackChannelName.getNullable("slackChannelName")) + + /** The slack channel id connected to the project. */ + fun slackChannelId(): Optional = + Optional.ofNullable(slackChannelId.getNullable("slackChannelId")) + + 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 + + /** Whether the project is a sample project or a user-created project. */ + @JsonProperty("sample") @ExcludeMissing fun _sample() = sample + + /** 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 + + /** The number of unread notifications in the project. */ + @JsonProperty("unreadNotificationCount") + @ExcludeMissing + fun _unreadNotificationCount() = unreadNotificationCount + + /** Links to the project. */ + @JsonProperty("links") @ExcludeMissing fun _links() = links + + /** Whether slack channel notifications are enabled for the project. */ + @JsonProperty("slackChannelNotificationsEnabled") + @ExcludeMissing + fun _slackChannelNotificationsEnabled() = slackChannelNotificationsEnabled + + /** The slack channel connected to the project. */ + @JsonProperty("slackChannelName") @ExcludeMissing fun _slackChannelName() = slackChannelName + + /** The slack channel id connected to the project. */ + @JsonProperty("slackChannelId") @ExcludeMissing fun _slackChannelId() = slackChannelId + + @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() + sample() + source() + taskType() + versionCount() + inferencePipelineCount() + goalCount() + developmentGoalCount() + monitoringGoalCount() + unreadNotificationCount() + links().validate() + slackChannelNotificationsEnabled() + slackChannelName() + slackChannelId() + gitRepo().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + this.id == other.id && + this.workspaceId == other.workspaceId && + this.creatorId == other.creatorId && + this.name == other.name && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.description == other.description && + this.sample == other.sample && + this.source == other.source && + this.taskType == other.taskType && + this.versionCount == other.versionCount && + this.inferencePipelineCount == other.inferencePipelineCount && + this.goalCount == other.goalCount && + this.developmentGoalCount == other.developmentGoalCount && + this.monitoringGoalCount == other.monitoringGoalCount && + this.unreadNotificationCount == other.unreadNotificationCount && + this.links == other.links && + this.slackChannelNotificationsEnabled == other.slackChannelNotificationsEnabled && + this.slackChannelName == other.slackChannelName && + this.slackChannelId == other.slackChannelId && + this.gitRepo == other.gitRepo && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + workspaceId, + creatorId, + name, + dateCreated, + dateUpdated, + description, + sample, + source, + taskType, + versionCount, + inferencePipelineCount, + goalCount, + developmentGoalCount, + monitoringGoalCount, + unreadNotificationCount, + links, + slackChannelNotificationsEnabled, + slackChannelName, + slackChannelId, + gitRepo, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Item{id=$id, workspaceId=$workspaceId, creatorId=$creatorId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, description=$description, sample=$sample, source=$source, taskType=$taskType, versionCount=$versionCount, inferencePipelineCount=$inferencePipelineCount, goalCount=$goalCount, developmentGoalCount=$developmentGoalCount, monitoringGoalCount=$monitoringGoalCount, unreadNotificationCount=$unreadNotificationCount, links=$links, slackChannelNotificationsEnabled=$slackChannelNotificationsEnabled, slackChannelName=$slackChannelName, slackChannelId=$slackChannelId, gitRepo=$gitRepo, additionalProperties=$additionalProperties}" + + 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 sample: 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 unreadNotificationCount: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var slackChannelNotificationsEnabled: JsonField = JsonMissing.of() + private var slackChannelName: JsonField = JsonMissing.of() + private var slackChannelId: 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.sample = item.sample + 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.unreadNotificationCount = item.unreadNotificationCount + this.links = item.links + this.slackChannelNotificationsEnabled = item.slackChannelNotificationsEnabled + this.slackChannelName = item.slackChannelName + this.slackChannelId = item.slackChannelId + 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 + } + + /** Whether the project is a sample project or a user-created project. */ + fun sample(sample: Boolean) = sample(JsonField.of(sample)) + + /** Whether the project is a sample project or a user-created project. */ + @JsonProperty("sample") + @ExcludeMissing + fun sample(sample: JsonField) = apply { this.sample = sample } + + /** 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 + } + + /** The number of unread notifications in the project. */ + fun unreadNotificationCount(unreadNotificationCount: Long) = + unreadNotificationCount(JsonField.of(unreadNotificationCount)) + + /** The number of unread notifications in the project. */ + @JsonProperty("unreadNotificationCount") + @ExcludeMissing + fun unreadNotificationCount(unreadNotificationCount: JsonField) = apply { + this.unreadNotificationCount = unreadNotificationCount + } + + /** 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 } + + /** Whether slack channel notifications are enabled for the project. */ + fun slackChannelNotificationsEnabled(slackChannelNotificationsEnabled: Boolean) = + slackChannelNotificationsEnabled(JsonField.of(slackChannelNotificationsEnabled)) + + /** Whether slack channel notifications are enabled for the project. */ + @JsonProperty("slackChannelNotificationsEnabled") + @ExcludeMissing + fun slackChannelNotificationsEnabled( + slackChannelNotificationsEnabled: JsonField + ) = apply { this.slackChannelNotificationsEnabled = slackChannelNotificationsEnabled } + + /** The slack channel connected to the project. */ + fun slackChannelName(slackChannelName: String) = + slackChannelName(JsonField.of(slackChannelName)) + + /** The slack channel connected to the project. */ + @JsonProperty("slackChannelName") + @ExcludeMissing + fun slackChannelName(slackChannelName: JsonField) = apply { + this.slackChannelName = slackChannelName + } + + /** The slack channel id connected to the project. */ + fun slackChannelId(slackChannelId: String) = + slackChannelId(JsonField.of(slackChannelId)) + + /** The slack channel id connected to the project. */ + @JsonProperty("slackChannelId") + @ExcludeMissing + fun slackChannelId(slackChannelId: JsonField) = apply { + this.slackChannelId = slackChannelId + } + + 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, + sample, + source, + taskType, + versionCount, + inferencePipelineCount, + goalCount, + developmentGoalCount, + monitoringGoalCount, + unreadNotificationCount, + links, + slackChannelNotificationsEnabled, + slackChannelName, + slackChannelId, + gitRepo, + additionalProperties.toUnmodifiable(), + ) + } + + /** 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 + + private var hashCode: Int = 0 + + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Links && + this.app == other.app && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(app, additionalProperties) + } + return hashCode + } + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + + 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.toUnmodifiable()) + } + } + + class Source + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Source && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val WEB = Source(JsonField.of("web")) + + @JvmField val API = Source(JsonField.of("api")) + + @JvmField val NULL = Source(JsonField.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() + } + + class TaskType + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaskType && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val LLM_BASE = TaskType(JsonField.of("llm-base")) + + @JvmField + val TABULAR_CLASSIFICATION = TaskType(JsonField.of("tabular-classification")) + + @JvmField val TABULAR_REGRESSION = TaskType(JsonField.of("tabular-regression")) + + @JvmField val TEXT_CLASSIFICATION = TaskType(JsonField.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() + } + + @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 + + private var hashCode: Int = 0 + + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GitRepo && + this.id == other.id && + this.gitId == other.gitId && + this.dateConnected == other.dateConnected && + this.dateUpdated == other.dateUpdated && + this.branch == other.branch && + this.name == other.name && + this.private_ == other.private_ && + this.slug == other.slug && + this.url == other.url && + this.rootDir == other.rootDir && + this.projectId == other.projectId && + this.gitAccountId == other.gitAccountId && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + gitId, + dateConnected, + dateUpdated, + branch, + name, + private_, + slug, + url, + rootDir, + projectId, + gitAccountId, + additionalProperties, + ) + } + return 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}" + + 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.toUnmodifiable(), + ) + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/Handlers.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/Handlers.kt new file mode 100644 index 0000000..7f8fa7c --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/Handlers.kt @@ -0,0 +1,130 @@ +@file:JvmName("Handlers") + +package org.openlayer.services + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.io.InputStream +import java.io.OutputStream +import org.openlayer.core.http.BinaryResponseContent +import org.openlayer.core.http.HttpResponse +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.BadRequestException +import org.openlayer.errors.InternalServerException +import org.openlayer.errors.NotFoundException +import org.openlayer.errors.OpenlayerError +import org.openlayer.errors.OpenlayerException +import org.openlayer.errors.PermissionDeniedException +import org.openlayer.errors.RateLimitException +import org.openlayer.errors.UnauthorizedException +import org.openlayer.errors.UnexpectedStatusCodeException +import org.openlayer.errors.UnprocessableEntityException + +@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandler + +private object EmptyHandler : Handler { + override fun handle(response: HttpResponse): Void? = null +} + +@JvmSynthetic internal fun stringHandler(): Handler = StringHandler + +@JvmSynthetic internal fun binaryHandler(): Handler = BinaryHandler + +private object StringHandler : Handler { + override fun handle(response: HttpResponse): String { + return response.body().readBytes().toString(Charsets.UTF_8) + } +} + +private object BinaryHandler : Handler { + override fun handle(response: HttpResponse): BinaryResponseContent { + return BinaryResponseContentImpl(response) + } +} + +@JvmSynthetic +internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler { + return object : Handler { + override fun handle(response: HttpResponse): T { + try { + return jsonMapper.readValue(response.body(), jacksonTypeRef()) + } catch (e: Exception) { + throw OpenlayerException("Error reading response", e) + } + } + } +} + +@JvmSynthetic +internal fun errorHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) + + return object : Handler { + override fun handle(response: HttpResponse): OpenlayerError { + try { + return handler.handle(response) + } catch (e: Exception) { + return OpenlayerError.builder().build() + } + } + } +} + +@JvmSynthetic +internal fun Handler.withErrorHandler(errorHandler: Handler): Handler { + return object : Handler { + override fun handle(response: HttpResponse): T { + when (val statusCode = response.statusCode()) { + in 200..299 -> return this@withErrorHandler.handle(response) + 400 -> throw BadRequestException(response.headers(), errorHandler.handle(response)) + 401 -> + throw UnauthorizedException(response.headers(), errorHandler.handle(response)) + 403 -> + throw PermissionDeniedException( + response.headers(), + errorHandler.handle(response) + ) + 404 -> throw NotFoundException(response.headers(), errorHandler.handle(response)) + 422 -> + throw UnprocessableEntityException( + response.headers(), + errorHandler.handle(response) + ) + 429 -> throw RateLimitException(response.headers(), errorHandler.handle(response)) + in 500..599 -> + throw InternalServerException( + statusCode, + response.headers(), + errorHandler.handle(response) + ) + else -> + throw UnexpectedStatusCodeException( + statusCode, + response.headers(), + StringHandler.handle(response) + ) + } + } + } +} + +class BinaryResponseContentImpl +constructor( + private val response: HttpResponse, +) : BinaryResponseContent { + override fun contentType(): String? { + return response.headers().get("Content-Type").firstOrNull() + } + + override fun body(): InputStream { + return response.body() + } + + override fun writeTo(outputStream: OutputStream) { + response.body().copyTo(outputStream) + } + + override fun close() { + response.body().close() + } +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/HttpRequestBodies.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/HttpRequestBodies.kt new file mode 100644 index 0000000..598a559 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/HttpRequestBodies.kt @@ -0,0 +1,114 @@ +@file:JvmName("HttpRequestBodies") + +package org.openlayer.services + +import com.fasterxml.jackson.databind.json.JsonMapper +import java.io.ByteArrayOutputStream +import java.io.OutputStream +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.openlayer.core.Enum +import org.openlayer.core.JsonValue +import org.openlayer.core.MultipartFormValue +import org.openlayer.core.http.HttpRequestBody +import org.openlayer.errors.OpenlayerException + +@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/org/openlayer/services/async/CommitServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsync.kt new file mode 100644 index 0000000..10a5d88 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsync.kt @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async + +import org.openlayer.services.async.commits.TestResultServiceAsync + +interface CommitServiceAsync { + + fun testResults(): TestResultServiceAsync +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsyncImpl.kt new file mode 100644 index 0000000..567dd1a --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/CommitServiceAsyncImpl.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async + +import org.openlayer.core.ClientOptions +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.services.async.commits.TestResultServiceAsync +import org.openlayer.services.async.commits.TestResultServiceAsyncImpl +import org.openlayer.services.errorHandler + +class CommitServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : CommitServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val testResults: TestResultServiceAsync by lazy { + TestResultServiceAsyncImpl(clientOptions) + } + + override fun testResults(): TestResultServiceAsync = testResults +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsync.kt new file mode 100644 index 0000000..12b92b1 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsync.kt @@ -0,0 +1,15 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async + +import org.openlayer.services.async.inferencePipelines.DataServiceAsync +import org.openlayer.services.async.inferencePipelines.TestResultServiceAsync + +interface InferencePipelineServiceAsync { + + fun data(): DataServiceAsync + + fun testResults(): TestResultServiceAsync +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsyncImpl.kt new file mode 100644 index 0000000..57e7721 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/InferencePipelineServiceAsyncImpl.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async + +import org.openlayer.core.ClientOptions +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.services.async.inferencePipelines.DataServiceAsync +import org.openlayer.services.async.inferencePipelines.DataServiceAsyncImpl +import org.openlayer.services.async.inferencePipelines.TestResultServiceAsync +import org.openlayer.services.async.inferencePipelines.TestResultServiceAsyncImpl +import org.openlayer.services.errorHandler + +class InferencePipelineServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : InferencePipelineServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val data: DataServiceAsync by lazy { DataServiceAsyncImpl(clientOptions) } + + private val testResults: TestResultServiceAsync by lazy { + TestResultServiceAsyncImpl(clientOptions) + } + + override fun data(): DataServiceAsync = data + + override fun testResults(): TestResultServiceAsync = testResults +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsync.kt new file mode 100644 index 0000000..b3fa807 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsync.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions +import org.openlayer.models.ProjectListParams +import org.openlayer.models.ProjectListResponse +import org.openlayer.services.async.projects.CommitServiceAsync +import org.openlayer.services.async.projects.InferencePipelineServiceAsync + +interface ProjectServiceAsync { + + fun commits(): CommitServiceAsync + + fun inferencePipelines(): InferencePipelineServiceAsync + + /** List the projects in a user's workspace. */ + @JvmOverloads + fun list( + params: ProjectListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsyncImpl.kt new file mode 100644 index 0000000..9cb3d2b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/ProjectServiceAsyncImpl.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.ProjectListParams +import org.openlayer.models.ProjectListResponse +import org.openlayer.services.async.projects.CommitServiceAsync +import org.openlayer.services.async.projects.CommitServiceAsyncImpl +import org.openlayer.services.async.projects.InferencePipelineServiceAsync +import org.openlayer.services.async.projects.InferencePipelineServiceAsyncImpl +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class ProjectServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val commits: CommitServiceAsync by lazy { CommitServiceAsyncImpl(clientOptions) } + + private val inferencePipelines: InferencePipelineServiceAsync by lazy { + InferencePipelineServiceAsyncImpl(clientOptions) + } + + override fun commits(): CommitServiceAsync = commits + + override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** List the projects in a user's workspace. */ + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/async/commits/TestResultServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsync.kt new file mode 100644 index 0000000..f4f1596 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async.commits + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions +import org.openlayer.models.CommitTestResultListParams +import org.openlayer.models.CommitTestResultListResponse + +interface TestResultServiceAsync { + + /** List the test results for a commit (project version). */ + @JvmOverloads + fun list( + params: CommitTestResultListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsyncImpl.kt new file mode 100644 index 0000000..a4fd2b0 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/commits/TestResultServiceAsyncImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async.commits + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.CommitTestResultListParams +import org.openlayer.models.CommitTestResultListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +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 test results for a 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/async/inferencePipelines/DataServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsync.kt new file mode 100644 index 0000000..d38c9de --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async.inferencePipelines + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions +import org.openlayer.models.InferencePipelineDataStreamParams +import org.openlayer.models.InferencePipelineDataStreamResponse + +interface DataServiceAsync { + + /** Stream production data to an inference pipeline in Openlayer. */ + @JvmOverloads + fun stream( + params: InferencePipelineDataStreamParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsyncImpl.kt new file mode 100644 index 0000000..0a525dd --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/DataServiceAsyncImpl.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async.inferencePipelines + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.InferencePipelineDataStreamParams +import org.openlayer.models.InferencePipelineDataStreamResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.json +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class DataServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : DataServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val streamHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Stream production data to an inference pipeline in Openlayer. */ + 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/async/inferencePipelines/TestResultServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsync.kt new file mode 100644 index 0000000..6bc53cc --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async.inferencePipelines + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions +import org.openlayer.models.InferencePipelineTestResultListParams +import org.openlayer.models.InferencePipelineTestResultListResponse + +interface TestResultServiceAsync { + + /** List the test results under an inference pipeline. */ + @JvmOverloads + fun list( + params: InferencePipelineTestResultListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt new file mode 100644 index 0000000..1bc0866 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/inferencePipelines/TestResultServiceAsyncImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async.inferencePipelines + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.InferencePipelineTestResultListParams +import org.openlayer.models.InferencePipelineTestResultListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +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 test results under 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/async/projects/CommitServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsync.kt new file mode 100644 index 0000000..1875026 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async.projects + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions +import org.openlayer.models.ProjectCommitListParams +import org.openlayer.models.ProjectCommitListResponse + +interface CommitServiceAsync { + + /** List the commits (project versions) under a project. */ + @JvmOverloads + fun list( + params: ProjectCommitListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsyncImpl.kt new file mode 100644 index 0000000..f9f3d2f --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/CommitServiceAsyncImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async.projects + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.ProjectCommitListParams +import org.openlayer.models.ProjectCommitListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class CommitServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : CommitServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List the commits (project versions) under 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/async/projects/InferencePipelineServiceAsync.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsync.kt new file mode 100644 index 0000000..32d2e12 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.async.projects + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.RequestOptions +import org.openlayer.models.ProjectInferencePipelineListParams +import org.openlayer.models.ProjectInferencePipelineListResponse + +interface InferencePipelineServiceAsync { + + /** List the inference pipelines in a project. */ + @JvmOverloads + fun list( + params: ProjectInferencePipelineListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsyncImpl.kt new file mode 100644 index 0000000..9a5fe84 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/async/projects/InferencePipelineServiceAsyncImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.async.projects + +import java.util.concurrent.CompletableFuture +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.ProjectInferencePipelineListParams +import org.openlayer.models.ProjectInferencePipelineListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class InferencePipelineServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : InferencePipelineServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/blocking/CommitService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitService.kt new file mode 100644 index 0000000..8aa2c72 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitService.kt @@ -0,0 +1,12 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking + +import org.openlayer.services.blocking.commits.TestResultService + +interface CommitService { + + fun testResults(): TestResultService +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitServiceImpl.kt new file mode 100644 index 0000000..cf56a53 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/CommitServiceImpl.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking + +import org.openlayer.core.ClientOptions +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.services.blocking.commits.TestResultService +import org.openlayer.services.blocking.commits.TestResultServiceImpl +import org.openlayer.services.errorHandler + +class CommitServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : CommitService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val testResults: TestResultService by lazy { TestResultServiceImpl(clientOptions) } + + override fun testResults(): TestResultService = testResults +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineService.kt new file mode 100644 index 0000000..5d9bf22 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineService.kt @@ -0,0 +1,15 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking + +import org.openlayer.services.blocking.inferencePipelines.DataService +import org.openlayer.services.blocking.inferencePipelines.TestResultService + +interface InferencePipelineService { + + fun data(): DataService + + fun testResults(): TestResultService +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineServiceImpl.kt new file mode 100644 index 0000000..bfcbe42 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/InferencePipelineServiceImpl.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking + +import org.openlayer.core.ClientOptions +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.services.blocking.inferencePipelines.DataService +import org.openlayer.services.blocking.inferencePipelines.DataServiceImpl +import org.openlayer.services.blocking.inferencePipelines.TestResultService +import org.openlayer.services.blocking.inferencePipelines.TestResultServiceImpl +import org.openlayer.services.errorHandler + +class InferencePipelineServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : InferencePipelineService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val data: DataService by lazy { DataServiceImpl(clientOptions) } + + private val testResults: TestResultService by lazy { TestResultServiceImpl(clientOptions) } + + override fun data(): DataService = data + + override fun testResults(): TestResultService = testResults +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectService.kt new file mode 100644 index 0000000..da82905 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectService.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking + +import org.openlayer.core.RequestOptions +import org.openlayer.models.ProjectListParams +import org.openlayer.models.ProjectListResponse +import org.openlayer.services.blocking.projects.CommitService +import org.openlayer.services.blocking.projects.InferencePipelineService + +interface ProjectService { + + fun commits(): CommitService + + fun inferencePipelines(): InferencePipelineService + + /** List the projects in a user's workspace. */ + @JvmOverloads + fun list( + params: ProjectListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectListResponse +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectServiceImpl.kt new file mode 100644 index 0000000..234a84e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/ProjectServiceImpl.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking + +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.ProjectListParams +import org.openlayer.models.ProjectListResponse +import org.openlayer.services.blocking.projects.CommitService +import org.openlayer.services.blocking.projects.CommitServiceImpl +import org.openlayer.services.blocking.projects.InferencePipelineService +import org.openlayer.services.blocking.projects.InferencePipelineServiceImpl +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class ProjectServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : ProjectService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val commits: CommitService by lazy { CommitServiceImpl(clientOptions) } + + private val inferencePipelines: InferencePipelineService by lazy { + InferencePipelineServiceImpl(clientOptions) + } + + override fun commits(): CommitService = commits + + override fun inferencePipelines(): InferencePipelineService = inferencePipelines + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** List the projects in a user's workspace. */ + override fun list( + params: ProjectListParams, + requestOptions: RequestOptions + ): ProjectListResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments("projects") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/blocking/commits/TestResultService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultService.kt new file mode 100644 index 0000000..b9fb6aa --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking.commits + +import org.openlayer.core.RequestOptions +import org.openlayer.models.CommitTestResultListParams +import org.openlayer.models.CommitTestResultListResponse + +interface TestResultService { + + /** List the test results for a commit (project version). */ + @JvmOverloads + fun list( + params: CommitTestResultListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CommitTestResultListResponse +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultServiceImpl.kt new file mode 100644 index 0000000..4074e01 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/commits/TestResultServiceImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.commits + +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.CommitTestResultListParams +import org.openlayer.models.CommitTestResultListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +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 test results for a 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/blocking/inferencePipelines/DataService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataService.kt new file mode 100644 index 0000000..44ba3d7 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking.inferencePipelines + +import org.openlayer.core.RequestOptions +import org.openlayer.models.InferencePipelineDataStreamParams +import org.openlayer.models.InferencePipelineDataStreamResponse + +interface DataService { + + /** Stream production data to an inference pipeline in Openlayer. */ + @JvmOverloads + fun stream( + params: InferencePipelineDataStreamParams, + requestOptions: RequestOptions = RequestOptions.none() + ): InferencePipelineDataStreamResponse +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceImpl.kt new file mode 100644 index 0000000..06e6b2e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.inferencePipelines + +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.InferencePipelineDataStreamParams +import org.openlayer.models.InferencePipelineDataStreamResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.json +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class DataServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : DataService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val streamHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Stream production data to an inference pipeline in Openlayer. */ + 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/blocking/inferencePipelines/TestResultService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultService.kt new file mode 100644 index 0000000..74c6cc0 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking.inferencePipelines + +import org.openlayer.core.RequestOptions +import org.openlayer.models.InferencePipelineTestResultListParams +import org.openlayer.models.InferencePipelineTestResultListResponse + +interface TestResultService { + + /** List the test results under an inference pipeline. */ + @JvmOverloads + fun list( + params: InferencePipelineTestResultListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): InferencePipelineTestResultListResponse +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceImpl.kt new file mode 100644 index 0000000..7d13d13 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.inferencePipelines + +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.InferencePipelineTestResultListParams +import org.openlayer.models.InferencePipelineTestResultListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +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 test results under 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/blocking/projects/CommitService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitService.kt new file mode 100644 index 0000000..9c143ef --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking.projects + +import org.openlayer.core.RequestOptions +import org.openlayer.models.ProjectCommitListParams +import org.openlayer.models.ProjectCommitListResponse + +interface CommitService { + + /** List the commits (project versions) under a project. */ + @JvmOverloads + fun list( + params: ProjectCommitListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectCommitListResponse +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitServiceImpl.kt new file mode 100644 index 0000000..33558b0 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/CommitServiceImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.projects + +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.ProjectCommitListParams +import org.openlayer.models.ProjectCommitListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class CommitServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : CommitService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** List the commits (project versions) under 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/org/openlayer/services/blocking/projects/InferencePipelineService.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineService.kt new file mode 100644 index 0000000..2d6c42a --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package org.openlayer.services.blocking.projects + +import org.openlayer.core.RequestOptions +import org.openlayer.models.ProjectInferencePipelineListParams +import org.openlayer.models.ProjectInferencePipelineListResponse + +interface InferencePipelineService { + + /** List the inference pipelines in a project. */ + @JvmOverloads + fun list( + params: ProjectInferencePipelineListParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectInferencePipelineListResponse +} diff --git a/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceImpl.kt new file mode 100644 index 0000000..0d22af4 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceImpl.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.projects + +import org.openlayer.core.ClientOptions +import org.openlayer.core.RequestOptions +import org.openlayer.core.http.HttpMethod +import org.openlayer.core.http.HttpRequest +import org.openlayer.core.http.HttpResponse.Handler +import org.openlayer.errors.OpenlayerError +import org.openlayer.models.ProjectInferencePipelineListParams +import org.openlayer.models.ProjectInferencePipelineListResponse +import org.openlayer.services.errorHandler +import org.openlayer.services.jsonHandler +import org.openlayer.services.withErrorHandler + +class InferencePipelineServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : InferencePipelineService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + 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) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(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/test/kotlin/org/openlayer/TestServerExtension.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/TestServerExtension.kt new file mode 100644 index 0000000..01e0651 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/TestServerExtension.kt @@ -0,0 +1,62 @@ +package org.openlayer + +import java.lang.RuntimeException +import java.net.URL +import org.junit.jupiter.api.extension.BeforeAllCallback +import org.junit.jupiter.api.extension.ConditionEvaluationResult +import org.junit.jupiter.api.extension.ExecutionCondition +import org.junit.jupiter.api.extension.ExtensionContext + +class TestServerExtension : BeforeAllCallback, ExecutionCondition { + + override fun beforeAll(context: ExtensionContext?) { + try { + URL(BASE_URL).openConnection().connect() + } catch (e: Exception) { + throw RuntimeException( + """ + The test suite will not run without a mock Prism server running against your OpenAPI spec. + + You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests + that require the mock server. + + To fix: + + 1. Install Prism (requires Node 16+): + + With npm: + $ npm install -g @stoplight/prism-cli + + With yarn: + $ yarn global add @stoplight/prism-cli + + 2. Run the mock server + + To run the server, pass in the path of your OpenAPI spec to the prism command: + $ prism mock path/to/your.openapi.yml + """ + .trimIndent(), + e + ) + } + } + + override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { + return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) + } else { + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) + } + } + + companion object { + + val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" + + const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/client/OpenlayerClientTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/client/OpenlayerClientTest.kt new file mode 100644 index 0000000..8259b0a --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/client/OpenlayerClientTest.kt @@ -0,0 +1,5 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.client + +class OpenlayerClientTest diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/HttpRequestTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/HttpRequestTest.kt new file mode 100644 index 0000000..5ddca6e --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/HttpRequestTest.kt @@ -0,0 +1,22 @@ +package org.openlayer.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HttpRequestTest { + + @Test + fun caseInsensitiveHeadersAccessors() { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .putHeader("something_lowercase", "lowercase") + .putHeader("Something_Capitalized", "Capitalized") + .putHeader("SOMETHING_UPPERCASE", "UPPERCASE") + .build() + assertThat(request.headers.get("SOMETHING_LOWERCASE").getOrNull(0)).isEqualTo("lowercase") + assertThat(request.headers.get("something_capitalized").getOrNull(0)) + .isEqualTo("Capitalized") + assertThat(request.headers.get("Something_Uppercase").getOrNull(0)).isEqualTo("UPPERCASE") + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/RetryingHttpClientTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/RetryingHttpClientTest.kt new file mode 100644 index 0000000..dc8258b --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/RetryingHttpClientTest.kt @@ -0,0 +1,111 @@ +package org.openlayer.core.http + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.github.tomakehurst.wiremock.stubbing.Scenario +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.openlayer.client.okhttp.OkHttpClient + +@WireMockTest +internal class RetryingHttpClientTest { + + private lateinit var httpClient: HttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + httpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + resetAllScenarios() + } + + @Test + fun byDefaultShouldNotAddIdempotencyHeaderToRequest() { + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() + val response = retryingClient.execute(request) + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + } + + @Test + fun whenProvidedShouldAddIdempotencyHeaderToRequest() { + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + stubFor( + post(urlPathEqualTo("/something")) + .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) + .willReturn(ok()) + ) + val retryingClient = + RetryingHttpClient.builder() + .httpClient(httpClient) + .idempotencyHeader("X-Some-Header") + .build() + val response = retryingClient.execute(request) + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + } + + @Test + fun retryAfterHeader() { + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // first we fail with a retry after header given as a date + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we fail with a retry after header given as a delay + .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 + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = + RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val response = retryingClient.execute(request) + assertThat(response.statusCode()).isEqualTo(200) + verify(3, postRequestedFor(urlPathEqualTo("/something"))) + } + + @Test + fun retryAfterMsHeader() { + val request = + HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build() + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After-Ms", "10")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = + RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() + val response = retryingClient.execute(request) + assertThat(response.statusCode()).isEqualTo(200) + verify(2, postRequestedFor(urlPathEqualTo("/something"))) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/SerializerTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/SerializerTest.kt new file mode 100644 index 0000000..6b50f24 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/core/http/SerializerTest.kt @@ -0,0 +1,105 @@ +package org.openlayer.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 java.util.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.core.* + +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.toUnmodifiable(), + ) + } + } + + @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/org/openlayer/models/CommitTestResultListParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/CommitTestResultListParamsTest.kt new file mode 100644 index 0000000..cfdf441 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/CommitTestResultListParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.models.* + +class CommitTestResultListParamsTest { + + @Test + fun createCommitTestResultListParams() { + CommitTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(123L) + .perPage(100L) + .status(CommitTestResultListParams.Status.RUNNING) + .type(CommitTestResultListParams.Type.INTEGRITY) + .build() + } + + @Test + fun getQueryParams() { + val params = + CommitTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(123L) + .perPage(100L) + .status(CommitTestResultListParams.Status.RUNNING) + .type(CommitTestResultListParams.Type.INTEGRITY) + .build() + val expected = mutableMapOf>() + expected.put("includeArchived", listOf("true")) + expected.put("page", listOf("123")) + expected.put("perPage", listOf("100")) + expected.put("status", listOf(CommitTestResultListParams.Status.RUNNING.toString())) + expected.put("type", listOf(CommitTestResultListParams.Type.INTEGRITY.toString())) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + CommitTestResultListParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + CommitTestResultListParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "id" + 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/org/openlayer/models/CommitTestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/CommitTestResultListResponseTest.kt new file mode 100644 index 0000000..fa2e03b --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/CommitTestResultListResponseTest.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.core.JsonNull +import org.openlayer.core.JsonValue + +class CommitTestResultListResponseTest { + + @Test + fun createCommitTestResultListResponse() { + val commitTestResultListResponse = + CommitTestResultListResponse.builder() + ._meta( + CommitTestResultListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + .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(123L) + .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(JsonNull.of()) + .name("No duplicate rows") + .number(123L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(true) + .thresholds( + listOf( + CommitTestResultListResponse.Item.Goal.Threshold + .builder() + .insightName("duplicateRowCount") + .insightParameters( + listOf(JsonValue.from(mapOf())) + ) + .measurement("duplicateRowCount") + .operator("<=") + .value( + CommitTestResultListResponse.Item.Goal.Threshold + .Value + .ofDouble(42.23) + ) + .build() + ) + ) + .type("integrity") + .archived(true) + .delayWindow(42.23) + .evaluationWindow(42.23) + .usesMlModel(true) + .usesProductionData(true) + .usesReferenceDataset(true) + .usesTrainingDataset(true) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + ) + .build() + assertThat(commitTestResultListResponse).isNotNull + assertThat(commitTestResultListResponse._meta()) + .isEqualTo( + CommitTestResultListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + 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(123L) + .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(JsonNull.of()) + .name("No duplicate rows") + .number(123L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(true) + .thresholds( + listOf( + CommitTestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .insightParameters( + listOf(JsonValue.from(mapOf())) + ) + .measurement("duplicateRowCount") + .operator("<=") + .value( + CommitTestResultListResponse.Item.Goal.Threshold.Value + .ofDouble(42.23) + ) + .build() + ) + ) + .type("integrity") + .archived(true) + .delayWindow(42.23) + .evaluationWindow(42.23) + .usesMlModel(true) + .usesProductionData(true) + .usesReferenceDataset(true) + .usesTrainingDataset(true) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamParamsTest.kt new file mode 100644 index 0000000..466b844 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamParamsTest.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.core.JsonValue +import org.openlayer.models.* + +class InferencePipelineDataStreamParamsTest { + + @Test + fun createInferencePipelineDataStreamParams() { + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt.builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + } + + @Test + fun getBody() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_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().build())) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + InferencePipelineDataStreamParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + InferencePipelineDataStreamParams.Config.ofLlmData( + InferencePipelineDataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().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().build())) + } + + @Test + fun getPathParam() { + val params = + InferencePipelineDataStreamParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + InferencePipelineDataStreamParams.Config.ofLlmData( + InferencePipelineDataStreamParams.Config.LlmData.builder() + .outputColumnName("output") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + assertThat(params).isNotNull + // path param "id" + 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/org/openlayer/models/InferencePipelineDataStreamResponseTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamResponseTest.kt new file mode 100644 index 0000000..5721590 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineDataStreamResponseTest.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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/org/openlayer/models/InferencePipelineTestResultListParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineTestResultListParamsTest.kt new file mode 100644 index 0000000..7871212 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineTestResultListParamsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.models.* + +class InferencePipelineTestResultListParamsTest { + + @Test + fun createInferencePipelineTestResultListParams() { + InferencePipelineTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(123L) + .perPage(100L) + .status(InferencePipelineTestResultListParams.Status.RUNNING) + .type(InferencePipelineTestResultListParams.Type.INTEGRITY) + .build() + } + + @Test + fun getQueryParams() { + val params = + InferencePipelineTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(123L) + .perPage(100L) + .status(InferencePipelineTestResultListParams.Status.RUNNING) + .type(InferencePipelineTestResultListParams.Type.INTEGRITY) + .build() + val expected = mutableMapOf>() + expected.put("includeArchived", listOf("true")) + expected.put("page", listOf("123")) + expected.put("perPage", listOf("100")) + expected.put( + "status", + listOf(InferencePipelineTestResultListParams.Status.RUNNING.toString()) + ) + expected.put( + "type", + listOf(InferencePipelineTestResultListParams.Type.INTEGRITY.toString()) + ) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + InferencePipelineTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + InferencePipelineTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "id" + 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/org/openlayer/models/InferencePipelineTestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineTestResultListResponseTest.kt new file mode 100644 index 0000000..e65cc60 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/InferencePipelineTestResultListResponseTest.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.core.JsonNull +import org.openlayer.core.JsonValue + +class InferencePipelineTestResultListResponseTest { + + @Test + fun createInferencePipelineTestResultListResponse() { + val inferencePipelineTestResultListResponse = + InferencePipelineTestResultListResponse.builder() + ._meta( + InferencePipelineTestResultListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + .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(123L) + .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(JsonNull.of()) + .name("No duplicate rows") + .number(123L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(true) + .thresholds( + listOf( + InferencePipelineTestResultListResponse.Item.Goal + .Threshold + .builder() + .insightName("duplicateRowCount") + .insightParameters( + listOf(JsonValue.from(mapOf())) + ) + .measurement("duplicateRowCount") + .operator("<=") + .value( + InferencePipelineTestResultListResponse.Item + .Goal + .Threshold + .Value + .ofDouble(42.23) + ) + .build() + ) + ) + .type("integrity") + .archived(true) + .delayWindow(42.23) + .evaluationWindow(42.23) + .usesMlModel(true) + .usesProductionData(true) + .usesReferenceDataset(true) + .usesTrainingDataset(true) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + ) + .build() + assertThat(inferencePipelineTestResultListResponse).isNotNull + assertThat(inferencePipelineTestResultListResponse._meta()) + .isEqualTo( + InferencePipelineTestResultListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + 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(123L) + .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(JsonNull.of()) + .name("No duplicate rows") + .number(123L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(true) + .thresholds( + listOf( + InferencePipelineTestResultListResponse.Item.Goal.Threshold + .builder() + .insightName("duplicateRowCount") + .insightParameters( + listOf(JsonValue.from(mapOf())) + ) + .measurement("duplicateRowCount") + .operator("<=") + .value( + InferencePipelineTestResultListResponse.Item.Goal + .Threshold + .Value + .ofDouble(42.23) + ) + .build() + ) + ) + .type("integrity") + .archived(true) + .delayWindow(42.23) + .evaluationWindow(42.23) + .usesMlModel(true) + .usesProductionData(true) + .usesReferenceDataset(true) + .usesTrainingDataset(true) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListParamsTest.kt new file mode 100644 index 0000000..bb52fa3 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.models.* + +class ProjectCommitListParamsTest { + + @Test + fun createProjectCommitListParams() { + ProjectCommitListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(123L) + .perPage(100L) + .build() + } + + @Test + fun getQueryParams() { + val params = + ProjectCommitListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(123L) + .perPage(100L) + .build() + val expected = mutableMapOf>() + expected.put("page", listOf("123")) + expected.put("perPage", listOf("100")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + ProjectCommitListParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + ProjectCommitListParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + assertThat(params).isNotNull + // path param "id" + 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/org/openlayer/models/ProjectCommitListResponseTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListResponseTest.kt new file mode 100644 index 0000000..cd1982f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectCommitListResponseTest.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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() + ._meta( + ProjectCommitListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + .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(123L) + .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(123L) + .gitCommitUrl("string") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(123L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(123L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(ProjectCommitListResponse.Item.Status.QUEUED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(123L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(true) + .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._meta()) + .isEqualTo( + ProjectCommitListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + 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(123L) + .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(123L) + .gitCommitUrl("string") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(123L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(123L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(ProjectCommitListResponse.Item.Status.QUEUED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(123L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(true) + .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/org/openlayer/models/ProjectInferencePipelineListParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectInferencePipelineListParamsTest.kt new file mode 100644 index 0000000..d4538e1 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectInferencePipelineListParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.models.* + +class ProjectInferencePipelineListParamsTest { + + @Test + fun createProjectInferencePipelineListParams() { + ProjectInferencePipelineListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("string") + .page(123L) + .perPage(100L) + .build() + } + + @Test + fun getQueryParams() { + val params = + ProjectInferencePipelineListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("string") + .page(123L) + .perPage(100L) + .build() + val expected = mutableMapOf>() + expected.put("name", listOf("string")) + expected.put("page", listOf("123")) + expected.put("perPage", listOf("100")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + ProjectInferencePipelineListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getPathParam() { + val params = + ProjectInferencePipelineListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "id" + 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/org/openlayer/models/ProjectInferencePipelineListResponseTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectInferencePipelineListResponseTest.kt new file mode 100644 index 0000000..70d97a9 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectInferencePipelineListResponseTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +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() + ._meta( + ProjectInferencePipelineListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + .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(123L) + .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(123L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(ProjectInferencePipelineListResponse.Item.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(123L) + .referenceDatasetUri("s3://...") + .storageType( + ProjectInferencePipelineListResponse.Item.StorageType.LOCAL + ) + .build() + ) + ) + .build() + assertThat(projectInferencePipelineListResponse).isNotNull + assertThat(projectInferencePipelineListResponse._meta()) + .isEqualTo( + ProjectInferencePipelineListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + 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(123L) + .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(123L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(ProjectInferencePipelineListResponse.Item.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(123L) + .referenceDatasetUri("s3://...") + .storageType(ProjectInferencePipelineListResponse.Item.StorageType.LOCAL) + .build() + ) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListParamsTest.kt new file mode 100644 index 0000000..0659e48 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.openlayer.models.* + +class ProjectListParamsTest { + + @Test + fun createProjectListParams() { + ProjectListParams.builder() + .name("string") + .page(123L) + .perPage(100L) + .taskType(ProjectListParams.TaskType.LLM_BASE) + .build() + } + + @Test + fun getQueryParams() { + val params = + ProjectListParams.builder() + .name("string") + .page(123L) + .perPage(100L) + .taskType(ProjectListParams.TaskType.LLM_BASE) + .build() + val expected = mutableMapOf>() + expected.put("name", listOf("string")) + expected.put("page", listOf("123")) + expected.put("perPage", listOf("100")) + expected.put("taskType", listOf(ProjectListParams.TaskType.LLM_BASE.toString())) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = ProjectListParams.builder().build() + val expected = mutableMapOf>() + assertThat(params.getQueryParams()).isEqualTo(expected) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListResponseTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListResponseTest.kt new file mode 100644 index 0000000..cf56860 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/models/ProjectListResponseTest.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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() + ._meta( + ProjectListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .build() + ) + .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(123L) + .goalCount(123L) + .inferencePipelineCount(123L) + .links( + ProjectListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(123L) + .name("My Project") + .sample(true) + .source(ProjectListResponse.Item.Source.WEB) + .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) + .versionCount(123L) + .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(123L) + .name("string") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("string") + .url("string") + .branch("string") + .rootDir("string") + .build() + ) + .slackChannelId("C01B2PZQX1Z") + .slackChannelName("#my-project") + .slackChannelNotificationsEnabled(true) + .unreadNotificationCount(123L) + .build() + ) + ) + .build() + assertThat(projectListResponse).isNotNull + assertThat(projectListResponse._meta()) + .isEqualTo( + ProjectListResponse._Meta + .builder() + .page(123L) + .perPage(100L) + .totalItems(123L) + .totalPages(123L) + .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(123L) + .goalCount(123L) + .inferencePipelineCount(123L) + .links( + ProjectListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(123L) + .name("My Project") + .sample(true) + .source(ProjectListResponse.Item.Source.WEB) + .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) + .versionCount(123L) + .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(123L) + .name("string") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("string") + .url("string") + .branch("string") + .rootDir("string") + .build() + ) + .slackChannelId("C01B2PZQX1Z") + .slackChannelName("#my-project") + .slackChannelNotificationsEnabled(true) + .unreadNotificationCount(123L) + .build() + ) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/ErrorHandlingTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/ErrorHandlingTest.kt new file mode 100644 index 0000000..6c4e09f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/ErrorHandlingTest.kt @@ -0,0 +1,679 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services + +import com.fasterxml.jackson.databind.json.JsonMapper +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.get +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 +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.google.common.collect.ImmutableListMultimap +import com.google.common.collect.ListMultimap +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy +import org.assertj.core.api.InstanceOfAssertFactories +import org.assertj.guava.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.openlayer.client.OpenlayerClient +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.core.JsonString +import org.openlayer.core.JsonValue +import org.openlayer.core.jsonMapper +import org.openlayer.errors.BadRequestException +import org.openlayer.errors.InternalServerException +import org.openlayer.errors.NotFoundException +import org.openlayer.errors.OpenlayerError +import org.openlayer.errors.OpenlayerException +import org.openlayer.errors.PermissionDeniedException +import org.openlayer.errors.RateLimitException +import org.openlayer.errors.UnauthorizedException +import org.openlayer.errors.UnexpectedStatusCodeException +import org.openlayer.errors.UnprocessableEntityException +import org.openlayer.models.* + +@WireMockTest +class ErrorHandlingTest { + + private val JSON_MAPPER: JsonMapper = jsonMapper() + + private val OPENLAYER_ERROR: OpenlayerError = + OpenlayerError.builder().putAdditionalProperty("key", JsonString.of("value")).build() + + private lateinit var client: OpenlayerClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + OpenlayerOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.getHttpBaseUrl()) + .apiKey("My API Key") + .build() + } + + @Test + fun dataStream200() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().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) + } + + @Test + fun dataStream400() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(400).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertBadRequest(e, ImmutableListMultimap.of("Foo", "Bar"), OPENLAYER_ERROR) + }) + } + + @Test + fun dataStream401() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().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, ImmutableListMultimap.of("Foo", "Bar"), OPENLAYER_ERROR) + }) + } + + @Test + fun dataStream403() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(403).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertPermissionDenied(e, ImmutableListMultimap.of("Foo", "Bar"), OPENLAYER_ERROR) + }) + } + + @Test + fun dataStream404() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(404).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertNotFound(e, ImmutableListMultimap.of("Foo", "Bar"), OPENLAYER_ERROR) + }) + } + + @Test + fun dataStream422() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(422).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertUnprocessableEntity( + e, + ImmutableListMultimap.of("Foo", "Bar"), + OPENLAYER_ERROR + ) + }) + } + + @Test + fun dataStream429() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(429).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertRateLimit(e, ImmutableListMultimap.of("Foo", "Bar"), OPENLAYER_ERROR) + }) + } + + @Test + fun dataStream500() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(500).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertInternalServer(e, ImmutableListMultimap.of("Foo", "Bar"), OPENLAYER_ERROR) + }) + } + + @Test + fun unexpectedStatusCode() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor( + post(anyUrl()) + .willReturn(status(999).withHeader("Foo", "Bar").withBody(toJson(OPENLAYER_ERROR))) + ) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertUnexpectedStatusCodeException( + e, + 999, + ImmutableListMultimap.of("Foo", "Bar"), + toJson(OPENLAYER_ERROR) + ) + }) + } + + @Test + fun invalidBody() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().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") + }) + } + + @Test + fun invalidErrorBody() { + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + + stubFor(post(anyUrl()).willReturn(status(400).withBody("Not JSON"))) + + assertThatThrownBy({ client.inferencePipelines().data().stream(params) }) + .satisfies({ e -> + assertBadRequest(e, ImmutableListMultimap.of(), OpenlayerError.builder().build()) + }) + } + + private fun toJson(body: T): ByteArray { + return JSON_MAPPER.writeValueAsBytes(body) + } + + private fun assertUnexpectedStatusCodeException( + throwable: Throwable, + statusCode: Int, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertBadRequest( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertUnauthorized( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertPermissionDenied( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertNotFound( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertUnprocessableEntity( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertRateLimit( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } + + private fun assertInternalServer( + throwable: Throwable, + headers: ListMultimap, + 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()).containsAllEntriesOf(headers) + }) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/ServiceParamsTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/ServiceParamsTest.kt new file mode 100644 index 0000000..a636b68 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/ServiceParamsTest.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.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.get +import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.put +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.verify +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.openlayer.client.OpenlayerClient +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.core.JsonString +import org.openlayer.core.JsonValue +import org.openlayer.core.jsonMapper +import org.openlayer.models.* + +@WireMockTest +class ServiceParamsTest { + + private val JSON_MAPPER: JsonMapper = jsonMapper() + + private lateinit var client: OpenlayerClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + OpenlayerOkHttpClient.builder() + .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", JsonString.of("ghi890")) + + val params = + InferencePipelineDataStreamParams.builder() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .additionalHeaders(additionalHeaders) + .additionalBodyProperties(additionalBodyProperties) + .additionalQueryParams(additionalQueryParams) + .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())) + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/CommitServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/CommitServiceTest.kt new file mode 100644 index 0000000..25e1b88 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/CommitServiceTest.kt @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking + +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) class CommitServiceTest diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/InferencePipelineServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/InferencePipelineServiceTest.kt new file mode 100644 index 0000000..8f419a4 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/InferencePipelineServiceTest.kt @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking + +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) class InferencePipelineServiceTest diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/ProjectServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/ProjectServiceTest.kt new file mode 100644 index 0000000..cb284db --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/ProjectServiceTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) +class ProjectServiceTest { + + @Test + fun callList() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val projectService = client.projects() + val projectListResponse = + projectService.list( + ProjectListParams.builder() + .name("string") + .page(123L) + .perPage(100L) + .taskType(ProjectListParams.TaskType.LLM_BASE) + .build() + ) + println(projectListResponse) + projectListResponse.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/commits/TestResultServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/commits/TestResultServiceTest.kt new file mode 100644 index 0000000..c432336 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/commits/TestResultServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.commits + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) +class TestResultServiceTest { + + @Test + fun callList() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val testResultService = client.commits().testResults() + val commitTestResultListResponse = + testResultService.list( + CommitTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(123L) + .perPage(100L) + .status(CommitTestResultListParams.Status.RUNNING) + .type(CommitTestResultListParams.Type.INTEGRITY) + .build() + ) + println(commitTestResultListResponse) + commitTestResultListResponse.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceTest.kt new file mode 100644 index 0000000..69a5a11 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/DataServiceTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.inferencePipelines + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.core.JsonValue +import org.openlayer.models.* + +@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() + .id("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("string")) + .latencyColumnName("latency") + .metadata(JsonValue.from(mapOf())) + .numOfTokenColumnName("num_tokens") + .prompt( + listOf( + InferencePipelineDataStreamParams.Config.LlmData.Prompt + .builder() + .content("{{ user_query }}") + .role("user") + .build() + ) + ) + .questionColumnName("question") + .timestampColumnName("timestamp") + .build() + ) + ) + .rows(listOf(InferencePipelineDataStreamParams.Row.builder().build())) + .build() + ) + println(inferencePipelineDataStreamResponse) + inferencePipelineDataStreamResponse.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceTest.kt new file mode 100644 index 0000000..0434c8e --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/inferencePipelines/TestResultServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.inferencePipelines + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) +class TestResultServiceTest { + + @Test + fun callList() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val testResultService = client.inferencePipelines().testResults() + val inferencePipelineTestResultListResponse = + testResultService.list( + InferencePipelineTestResultListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .includeArchived(true) + .page(123L) + .perPage(100L) + .status(InferencePipelineTestResultListParams.Status.RUNNING) + .type(InferencePipelineTestResultListParams.Type.INTEGRITY) + .build() + ) + println(inferencePipelineTestResultListResponse) + inferencePipelineTestResultListResponse.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/CommitServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/CommitServiceTest.kt new file mode 100644 index 0000000..24c188f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/CommitServiceTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.projects + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) +class CommitServiceTest { + + @Test + fun callList() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitService = client.projects().commits() + val projectCommitListResponse = + commitService.list( + ProjectCommitListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(123L) + .perPage(100L) + .build() + ) + println(projectCommitListResponse) + projectCommitListResponse.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceTest.kt b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceTest.kt new file mode 100644 index 0000000..9f7399f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/org/openlayer/services/blocking/projects/InferencePipelineServiceTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package org.openlayer.services.blocking.projects + +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.openlayer.TestServerExtension +import org.openlayer.client.okhttp.OpenlayerOkHttpClient +import org.openlayer.models.* + +@ExtendWith(TestServerExtension::class) +class InferencePipelineServiceTest { + + @Test + fun callList() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineService = client.projects().inferencePipelines() + val projectInferencePipelineListResponse = + inferencePipelineService.list( + ProjectInferencePipelineListParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("string") + .page(123L) + .perPage(100L) + .build() + ) + println(projectInferencePipelineListResponse) + projectInferencePipelineListResponse.validate() + } +} diff --git a/openlayer-java-lib/.keep b/openlayer-java-lib/.keep new file mode 100644 index 0000000..5e2c99f --- /dev/null +++ b/openlayer-java-lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/openlayer-java/build.gradle.kts b/openlayer-java/build.gradle.kts new file mode 100644 index 0000000..a4d8ebb --- /dev/null +++ b/openlayer-java/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + id("openlayer.kotlin") + id("openlayer.publish") +} + +dependencies { + api(project(":openlayer-java-client-okhttp")) +} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..8f98719 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file diff --git a/scripts/format b/scripts/format new file mode 100755 index 0000000..c6239fa --- /dev/null +++ b/scripts/format @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running spotlessApply" +./gradlew --build-cache --parallel --no-daemon spotlessApply diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 0000000..58753d0 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Build classes" +./gradlew --build-cache --parallel --no-daemon build testClasses -x test diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 0000000..fe89a1d --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stoplight/prism-cli@~5.8 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 0000000..72ed033 --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +./gradlew --build-cache --parallel --no-daemon test diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..1de5738 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,6 @@ +rootProject.name = "openlayer-java-root" + +include("openlayer-java") +include("openlayer-java-client-okhttp") +include("openlayer-java-core") +include("openlayer-java-example") From 7085086eec82ac7566d9670d469b5a0c9a9175d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:55:17 +0000 Subject: [PATCH 2/2] release: 0.1.0-alpha.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ README.md | 6 +++--- build.gradle.kts | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.release-please-manifest.json b/.release-please-manifest.json index c476280..ba6c348 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.0.1-alpha.0" + ".": "0.1.0-alpha.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9398600 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +## 0.1.0-alpha.1 (2024-06-24) + +Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/openlayer-ai/openlayer-java/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) + +### Features + +* **api:** update via SDK Studio ([#1](https://github.com/openlayer-ai/openlayer-java/issues/1)) ([6cb7408](https://github.com/openlayer-ai/openlayer-java/commit/6cb740885ec6cc7d489d2235473c6c412811d406)) diff --git a/README.md b/README.md index 1d8c59c..c027e07 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/org.openlayer/openlayer-java)](https://central.sonatype.com/artifact/org.openlayer/openlayer-java/0.0.1-alpha.0) +[![Maven Central](https://img.shields.io/maven-central/v/org.openlayer/openlayer-java)](https://central.sonatype.com/artifact/org.openlayer/openlayer-java/0.1.0-alpha.1) @@ -27,7 +27,7 @@ The REST API documentation can be found [on openlayer.com](https://openlayer.co ```kotlin -implementation("org.openlayer:openlayer-java:0.0.1-alpha.0") +implementation("org.openlayer:openlayer-java:0.1.0-alpha.1") ``` #### Maven @@ -36,7 +36,7 @@ implementation("org.openlayer:openlayer-java:0.0.1-alpha.0") org.openlayer openlayer-java - 0.0.1-alpha.0 + 0.1.0-alpha.1 ``` diff --git a/build.gradle.kts b/build.gradle.kts index bbd2896..1aa0b26 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "org.openlayer" - version = "0.0.1-alpha.0" // x-release-please-version + version = "0.1.0-alpha.1" // x-release-please-version } nexusPublishing {