diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cbe04bc..d47822c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,14 +65,18 @@ jobs: run: ./scripts/build - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/openlayer-java' + if: |- + github.repository == 'stainless-sdks/openlayer-java' && + !startsWith(github.ref, 'refs/heads/stl/') id: github-oidc uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Build and upload Maven artifacts - if: github.repository == 'stainless-sdks/openlayer-java' + if: |- + github.repository == 'stainless-sdks/openlayer-java' && + !startsWith(github.ref, 'refs/heads/stl/') env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 383dd5a3..4208b5cb 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.5.2" + ".": "0.6.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index f4bb289c..a47d0ba9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,3 +1,3 @@ -configured_endpoints: 27 -openapi_spec_hash: c70c3eccfe803e99c14e97e650b1e314 -config_hash: 1f7626e569e1a74574a58d7883170a0e +configured_endpoints: 28 +openapi_spec_hash: 5f7962599290c70cb47c05c3b29fdbd8 +config_hash: f1c0c034bd832878eb47146c51afdd55 diff --git a/CHANGELOG.md b/CHANGELOG.md index 82f7e63f..4ef87030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.6.0 (2026-03-06) + +Full Changelog: [v0.5.2...v0.6.0](https://github.com/openlayer-ai/openlayer-java/compare/v0.5.2...v0.6.0) + +### Features + +* **api:** update POST /rows to use list method name ([5fd64a9](https://github.com/openlayer-ai/openlayer-java/commit/5fd64a9fbe3c0218e9bd25d81d3341a9c92d37bc)) +* **closes OPEN-9425:** document /rows endpoint in API reference and … ([e9093d0](https://github.com/openlayer-ai/openlayer-java/commit/e9093d022dfd5a333252214f0a6a5f1eaf3049b7)) + + +### Chores + +* **internal:** bump palantir-java-format ([3b5458b](https://github.com/openlayer-ai/openlayer-java/commit/3b5458bd3c2dd9d7107e13834d39b69202a2199a)) +* **internal:** codegen related update ([d1f3122](https://github.com/openlayer-ai/openlayer-java/commit/d1f3122b9f64430fc58f5c6dc86c74aba371cd39)) +* **test:** do not count install time for mock server timeout ([e2cc9fd](https://github.com/openlayer-ai/openlayer-java/commit/e2cc9fd39b862bf6bf9eff79b205e078b16d9080)) + ## 0.5.2 (2026-02-25) Full Changelog: [v0.5.1...v0.5.2](https://github.com/openlayer-ai/openlayer-java/compare/v0.5.1...v0.5.2) diff --git a/README.md b/README.md index c82f5770..0c0d64bd 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.5.2) -[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.5.2/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.5.2) +[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.6.0) +[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.6.0/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.6.0) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.5.2). +The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.6.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [openlayer.com](https://openlayer.com ### Gradle ```kotlin -implementation("com.openlayer.api:openlayer-java:0.5.2") +implementation("com.openlayer.api:openlayer-java:0.6.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openlayer.api:openlayer-java:0.5.2") com.openlayer.api openlayer-java - 0.5.2 + 0.6.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 82f42add..44ed33be 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openlayer.api" - version = "0.5.2" // x-release-please-version + version = "0.6.0" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/openlayer.java.gradle.kts b/buildSrc/src/main/kotlin/openlayer.java.gradle.kts index 70fc33f4..8f4f902a 100644 --- a/buildSrc/src/main/kotlin/openlayer.java.gradle.kts +++ b/buildSrc/src/main/kotlin/openlayer.java.gradle.kts @@ -45,7 +45,7 @@ tasks.withType().configureEach { val palantir by configurations.creating dependencies { - palantir("com.palantir.javaformat:palantir-java-format:2.73.0") + palantir("com.palantir.javaformat:palantir-java-format:2.89.0") } fun registerPalantir( diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt index bc64c3b9..be2deb1a 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt @@ -214,13 +214,8 @@ private constructor( } } ?.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 - } + // If the API asks us to wait a certain amount of time, do what it says. + return Duration.ofNanos(retryAfterNanos.toLong()) } // Apply exponential backoff, but not more than the max. diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListParams.kt new file mode 100644 index 00000000..a3aa6e7b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListParams.kt @@ -0,0 +1,2959 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.BaseDeserializer +import com.openlayer.api.core.BaseSerializer +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.Params +import com.openlayer.api.core.allMaxBy +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.getOrThrow +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A list of rows for an inference pipeline. */ +class RowListParams +private constructor( + private val inferencePipelineId: String?, + private val asc: Boolean?, + private val page: Long?, + private val perPage: Long?, + private val sortColumn: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun inferencePipelineId(): Optional = Optional.ofNullable(inferencePipelineId) + + /** Whether or not to sort on the sortColumn in ascending order. */ + fun asc(): Optional = Optional.ofNullable(asc) + + /** The page to return in a paginated query. */ + fun page(): Optional = Optional.ofNullable(page) + + /** Maximum number of items to return per page. */ + fun perPage(): Optional = Optional.ofNullable(perPage) + + /** Name of the column to sort on */ + fun sortColumn(): Optional = Optional.ofNullable(sortColumn) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun columnFilters(): Optional> = body.columnFilters() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludeRowIdList(): Optional> = body.excludeRowIdList() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun notSearchQueryAnd(): Optional> = body.notSearchQueryAnd() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun notSearchQueryOr(): Optional> = body.notSearchQueryOr() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rowIdList(): Optional> = body.rowIdList() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun searchQueryAnd(): Optional> = body.searchQueryAnd() + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun searchQueryOr(): Optional> = body.searchQueryOr() + + /** + * Returns the raw JSON value of [columnFilters]. + * + * Unlike [columnFilters], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _columnFilters(): JsonField> = body._columnFilters() + + /** + * Returns the raw JSON value of [excludeRowIdList]. + * + * Unlike [excludeRowIdList], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _excludeRowIdList(): JsonField> = body._excludeRowIdList() + + /** + * Returns the raw JSON value of [notSearchQueryAnd]. + * + * Unlike [notSearchQueryAnd], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _notSearchQueryAnd(): JsonField> = body._notSearchQueryAnd() + + /** + * Returns the raw JSON value of [notSearchQueryOr]. + * + * Unlike [notSearchQueryOr], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _notSearchQueryOr(): JsonField> = body._notSearchQueryOr() + + /** + * Returns the raw JSON value of [rowIdList]. + * + * Unlike [rowIdList], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _rowIdList(): JsonField> = body._rowIdList() + + /** + * Returns the raw JSON value of [searchQueryAnd]. + * + * Unlike [searchQueryAnd], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _searchQueryAnd(): JsonField> = body._searchQueryAnd() + + /** + * Returns the raw JSON value of [searchQueryOr]. + * + * Unlike [searchQueryOr], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _searchQueryOr(): JsonField> = body._searchQueryOr() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RowListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RowListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RowListParams]. */ + class Builder internal constructor() { + + private var inferencePipelineId: String? = null + private var asc: Boolean? = null + private var page: Long? = null + private var perPage: Long? = null + private var sortColumn: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(rowListParams: RowListParams) = apply { + inferencePipelineId = rowListParams.inferencePipelineId + asc = rowListParams.asc + page = rowListParams.page + perPage = rowListParams.perPage + sortColumn = rowListParams.sortColumn + body = rowListParams.body.toBuilder() + additionalHeaders = rowListParams.additionalHeaders.toBuilder() + additionalQueryParams = rowListParams.additionalQueryParams.toBuilder() + } + + fun inferencePipelineId(inferencePipelineId: String?) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** + * Alias for calling [Builder.inferencePipelineId] with `inferencePipelineId.orElse(null)`. + */ + fun inferencePipelineId(inferencePipelineId: Optional) = + inferencePipelineId(inferencePipelineId.getOrNull()) + + /** Whether or not to sort on the sortColumn in ascending order. */ + fun asc(asc: Boolean?) = apply { this.asc = asc } + + /** + * Alias for [Builder.asc]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun asc(asc: Boolean) = asc(asc as Boolean?) + + /** Alias for calling [Builder.asc] with `asc.orElse(null)`. */ + fun asc(asc: Optional) = asc(asc.getOrNull()) + + /** The page to return in a paginated query. */ + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.getOrNull()) + + /** Name of the column to sort on */ + fun sortColumn(sortColumn: String?) = apply { this.sortColumn = sortColumn } + + /** Alias for calling [Builder.sortColumn] with `sortColumn.orElse(null)`. */ + fun sortColumn(sortColumn: Optional) = sortColumn(sortColumn.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [columnFilters] + * - [excludeRowIdList] + * - [notSearchQueryAnd] + * - [notSearchQueryOr] + * - [rowIdList] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun columnFilters(columnFilters: List?) = apply { + body.columnFilters(columnFilters) + } + + /** Alias for calling [Builder.columnFilters] with `columnFilters.orElse(null)`. */ + fun columnFilters(columnFilters: Optional>) = + columnFilters(columnFilters.getOrNull()) + + /** + * Sets [Builder.columnFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.columnFilters] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun columnFilters(columnFilters: JsonField>) = apply { + body.columnFilters(columnFilters) + } + + /** + * Adds a single [ColumnFilter] to [columnFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnFilter(columnFilter: ColumnFilter) = apply { + body.addColumnFilter(columnFilter) + } + + /** Alias for calling [addColumnFilter] with `ColumnFilter.ofSet(set)`. */ + fun addColumnFilter(set: ColumnFilter.SetColumnFilter) = apply { body.addColumnFilter(set) } + + /** Alias for calling [addColumnFilter] with `ColumnFilter.ofNumeric(numeric)`. */ + fun addColumnFilter(numeric: ColumnFilter.NumericColumnFilter) = apply { + body.addColumnFilter(numeric) + } + + /** Alias for calling [addColumnFilter] with `ColumnFilter.ofString(string)`. */ + fun addColumnFilter(string: ColumnFilter.StringColumnFilter) = apply { + body.addColumnFilter(string) + } + + fun excludeRowIdList(excludeRowIdList: List?) = apply { + body.excludeRowIdList(excludeRowIdList) + } + + /** Alias for calling [Builder.excludeRowIdList] with `excludeRowIdList.orElse(null)`. */ + fun excludeRowIdList(excludeRowIdList: Optional>) = + excludeRowIdList(excludeRowIdList.getOrNull()) + + /** + * Sets [Builder.excludeRowIdList] to an arbitrary JSON value. + * + * You should usually call [Builder.excludeRowIdList] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun excludeRowIdList(excludeRowIdList: JsonField>) = apply { + body.excludeRowIdList(excludeRowIdList) + } + + /** + * Adds a single [Long] to [Builder.excludeRowIdList]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludeRowIdList(excludeRowIdList: Long) = apply { + body.addExcludeRowIdList(excludeRowIdList) + } + + fun notSearchQueryAnd(notSearchQueryAnd: List?) = apply { + body.notSearchQueryAnd(notSearchQueryAnd) + } + + /** Alias for calling [Builder.notSearchQueryAnd] with `notSearchQueryAnd.orElse(null)`. */ + fun notSearchQueryAnd(notSearchQueryAnd: Optional>) = + notSearchQueryAnd(notSearchQueryAnd.getOrNull()) + + /** + * Sets [Builder.notSearchQueryAnd] to an arbitrary JSON value. + * + * You should usually call [Builder.notSearchQueryAnd] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun notSearchQueryAnd(notSearchQueryAnd: JsonField>) = apply { + body.notSearchQueryAnd(notSearchQueryAnd) + } + + /** + * Adds a single [String] to [Builder.notSearchQueryAnd]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNotSearchQueryAnd(notSearchQueryAnd: String) = apply { + body.addNotSearchQueryAnd(notSearchQueryAnd) + } + + fun notSearchQueryOr(notSearchQueryOr: List?) = apply { + body.notSearchQueryOr(notSearchQueryOr) + } + + /** Alias for calling [Builder.notSearchQueryOr] with `notSearchQueryOr.orElse(null)`. */ + fun notSearchQueryOr(notSearchQueryOr: Optional>) = + notSearchQueryOr(notSearchQueryOr.getOrNull()) + + /** + * Sets [Builder.notSearchQueryOr] to an arbitrary JSON value. + * + * You should usually call [Builder.notSearchQueryOr] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun notSearchQueryOr(notSearchQueryOr: JsonField>) = apply { + body.notSearchQueryOr(notSearchQueryOr) + } + + /** + * Adds a single [String] to [Builder.notSearchQueryOr]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNotSearchQueryOr(notSearchQueryOr: String) = apply { + body.addNotSearchQueryOr(notSearchQueryOr) + } + + fun rowIdList(rowIdList: List?) = apply { body.rowIdList(rowIdList) } + + /** Alias for calling [Builder.rowIdList] with `rowIdList.orElse(null)`. */ + fun rowIdList(rowIdList: Optional>) = rowIdList(rowIdList.getOrNull()) + + /** + * Sets [Builder.rowIdList] to an arbitrary JSON value. + * + * You should usually call [Builder.rowIdList] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rowIdList(rowIdList: JsonField>) = apply { body.rowIdList(rowIdList) } + + /** + * Adds a single [Long] to [Builder.rowIdList]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRowIdList(rowIdList: Long) = apply { body.addRowIdList(rowIdList) } + + fun searchQueryAnd(searchQueryAnd: List?) = apply { + body.searchQueryAnd(searchQueryAnd) + } + + /** Alias for calling [Builder.searchQueryAnd] with `searchQueryAnd.orElse(null)`. */ + fun searchQueryAnd(searchQueryAnd: Optional>) = + searchQueryAnd(searchQueryAnd.getOrNull()) + + /** + * Sets [Builder.searchQueryAnd] to an arbitrary JSON value. + * + * You should usually call [Builder.searchQueryAnd] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun searchQueryAnd(searchQueryAnd: JsonField>) = apply { + body.searchQueryAnd(searchQueryAnd) + } + + /** + * Adds a single [String] to [Builder.searchQueryAnd]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSearchQueryAnd(searchQueryAnd: String) = apply { + body.addSearchQueryAnd(searchQueryAnd) + } + + fun searchQueryOr(searchQueryOr: List?) = apply { + body.searchQueryOr(searchQueryOr) + } + + /** Alias for calling [Builder.searchQueryOr] with `searchQueryOr.orElse(null)`. */ + fun searchQueryOr(searchQueryOr: Optional>) = + searchQueryOr(searchQueryOr.getOrNull()) + + /** + * Sets [Builder.searchQueryOr] to an arbitrary JSON value. + * + * You should usually call [Builder.searchQueryOr] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun searchQueryOr(searchQueryOr: JsonField>) = apply { + body.searchQueryOr(searchQueryOr) + } + + /** + * Adds a single [String] to [Builder.searchQueryOr]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSearchQueryOr(searchQueryOr: String) = apply { body.addSearchQueryOr(searchQueryOr) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [RowListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RowListParams = + RowListParams( + inferencePipelineId, + asc, + page, + perPage, + sortColumn, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> inferencePipelineId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + asc?.let { put("asc", it.toString()) } + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + sortColumn?.let { put("sortColumn", it) } + putAll(additionalQueryParams) + } + .build() + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val columnFilters: JsonField>, + private val excludeRowIdList: JsonField>, + private val notSearchQueryAnd: JsonField>, + private val notSearchQueryOr: JsonField>, + private val rowIdList: JsonField>, + private val searchQueryAnd: JsonField>, + private val searchQueryOr: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("columnFilters") + @ExcludeMissing + columnFilters: JsonField> = JsonMissing.of(), + @JsonProperty("excludeRowIdList") + @ExcludeMissing + excludeRowIdList: JsonField> = JsonMissing.of(), + @JsonProperty("notSearchQueryAnd") + @ExcludeMissing + notSearchQueryAnd: JsonField> = JsonMissing.of(), + @JsonProperty("notSearchQueryOr") + @ExcludeMissing + notSearchQueryOr: JsonField> = JsonMissing.of(), + @JsonProperty("rowIdList") + @ExcludeMissing + rowIdList: JsonField> = JsonMissing.of(), + @JsonProperty("searchQueryAnd") + @ExcludeMissing + searchQueryAnd: JsonField> = JsonMissing.of(), + @JsonProperty("searchQueryOr") + @ExcludeMissing + searchQueryOr: JsonField> = JsonMissing.of(), + ) : this( + columnFilters, + excludeRowIdList, + notSearchQueryAnd, + notSearchQueryOr, + rowIdList, + searchQueryAnd, + searchQueryOr, + mutableMapOf(), + ) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun columnFilters(): Optional> = + columnFilters.getOptional("columnFilters") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun excludeRowIdList(): Optional> = + excludeRowIdList.getOptional("excludeRowIdList") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun notSearchQueryAnd(): Optional> = + notSearchQueryAnd.getOptional("notSearchQueryAnd") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun notSearchQueryOr(): Optional> = + notSearchQueryOr.getOptional("notSearchQueryOr") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rowIdList(): Optional> = rowIdList.getOptional("rowIdList") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun searchQueryAnd(): Optional> = searchQueryAnd.getOptional("searchQueryAnd") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun searchQueryOr(): Optional> = searchQueryOr.getOptional("searchQueryOr") + + /** + * Returns the raw JSON value of [columnFilters]. + * + * Unlike [columnFilters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("columnFilters") + @ExcludeMissing + fun _columnFilters(): JsonField> = columnFilters + + /** + * Returns the raw JSON value of [excludeRowIdList]. + * + * Unlike [excludeRowIdList], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("excludeRowIdList") + @ExcludeMissing + fun _excludeRowIdList(): JsonField> = excludeRowIdList + + /** + * Returns the raw JSON value of [notSearchQueryAnd]. + * + * Unlike [notSearchQueryAnd], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("notSearchQueryAnd") + @ExcludeMissing + fun _notSearchQueryAnd(): JsonField> = notSearchQueryAnd + + /** + * Returns the raw JSON value of [notSearchQueryOr]. + * + * Unlike [notSearchQueryOr], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("notSearchQueryOr") + @ExcludeMissing + fun _notSearchQueryOr(): JsonField> = notSearchQueryOr + + /** + * Returns the raw JSON value of [rowIdList]. + * + * Unlike [rowIdList], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rowIdList") + @ExcludeMissing + fun _rowIdList(): JsonField> = rowIdList + + /** + * Returns the raw JSON value of [searchQueryAnd]. + * + * Unlike [searchQueryAnd], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("searchQueryAnd") + @ExcludeMissing + fun _searchQueryAnd(): JsonField> = searchQueryAnd + + /** + * Returns the raw JSON value of [searchQueryOr]. + * + * Unlike [searchQueryOr], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("searchQueryOr") + @ExcludeMissing + fun _searchQueryOr(): JsonField> = searchQueryOr + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var columnFilters: JsonField>? = null + private var excludeRowIdList: JsonField>? = null + private var notSearchQueryAnd: JsonField>? = null + private var notSearchQueryOr: JsonField>? = null + private var rowIdList: JsonField>? = null + private var searchQueryAnd: JsonField>? = null + private var searchQueryOr: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + columnFilters = body.columnFilters.map { it.toMutableList() } + excludeRowIdList = body.excludeRowIdList.map { it.toMutableList() } + notSearchQueryAnd = body.notSearchQueryAnd.map { it.toMutableList() } + notSearchQueryOr = body.notSearchQueryOr.map { it.toMutableList() } + rowIdList = body.rowIdList.map { it.toMutableList() } + searchQueryAnd = body.searchQueryAnd.map { it.toMutableList() } + searchQueryOr = body.searchQueryOr.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun columnFilters(columnFilters: List?) = + columnFilters(JsonField.ofNullable(columnFilters)) + + /** Alias for calling [Builder.columnFilters] with `columnFilters.orElse(null)`. */ + fun columnFilters(columnFilters: Optional>) = + columnFilters(columnFilters.getOrNull()) + + /** + * Sets [Builder.columnFilters] to an arbitrary JSON value. + * + * You should usually call [Builder.columnFilters] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun columnFilters(columnFilters: JsonField>) = apply { + this.columnFilters = columnFilters.map { it.toMutableList() } + } + + /** + * Adds a single [ColumnFilter] to [columnFilters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addColumnFilter(columnFilter: ColumnFilter) = apply { + columnFilters = + (columnFilters ?: JsonField.of(mutableListOf())).also { + checkKnown("columnFilters", it).add(columnFilter) + } + } + + /** Alias for calling [addColumnFilter] with `ColumnFilter.ofSet(set)`. */ + fun addColumnFilter(set: ColumnFilter.SetColumnFilter) = + addColumnFilter(ColumnFilter.ofSet(set)) + + /** Alias for calling [addColumnFilter] with `ColumnFilter.ofNumeric(numeric)`. */ + fun addColumnFilter(numeric: ColumnFilter.NumericColumnFilter) = + addColumnFilter(ColumnFilter.ofNumeric(numeric)) + + /** Alias for calling [addColumnFilter] with `ColumnFilter.ofString(string)`. */ + fun addColumnFilter(string: ColumnFilter.StringColumnFilter) = + addColumnFilter(ColumnFilter.ofString(string)) + + fun excludeRowIdList(excludeRowIdList: List?) = + excludeRowIdList(JsonField.ofNullable(excludeRowIdList)) + + /** + * Alias for calling [Builder.excludeRowIdList] with `excludeRowIdList.orElse(null)`. + */ + fun excludeRowIdList(excludeRowIdList: Optional>) = + excludeRowIdList(excludeRowIdList.getOrNull()) + + /** + * Sets [Builder.excludeRowIdList] to an arbitrary JSON value. + * + * You should usually call [Builder.excludeRowIdList] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun excludeRowIdList(excludeRowIdList: JsonField>) = apply { + this.excludeRowIdList = excludeRowIdList.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.excludeRowIdList]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludeRowIdList(excludeRowIdList: Long) = apply { + this.excludeRowIdList = + (this.excludeRowIdList ?: JsonField.of(mutableListOf())).also { + checkKnown("excludeRowIdList", it).add(excludeRowIdList) + } + } + + fun notSearchQueryAnd(notSearchQueryAnd: List?) = + notSearchQueryAnd(JsonField.ofNullable(notSearchQueryAnd)) + + /** + * Alias for calling [Builder.notSearchQueryAnd] with `notSearchQueryAnd.orElse(null)`. + */ + fun notSearchQueryAnd(notSearchQueryAnd: Optional>) = + notSearchQueryAnd(notSearchQueryAnd.getOrNull()) + + /** + * Sets [Builder.notSearchQueryAnd] to an arbitrary JSON value. + * + * You should usually call [Builder.notSearchQueryAnd] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun notSearchQueryAnd(notSearchQueryAnd: JsonField>) = apply { + this.notSearchQueryAnd = notSearchQueryAnd.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.notSearchQueryAnd]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNotSearchQueryAnd(notSearchQueryAnd: String) = apply { + this.notSearchQueryAnd = + (this.notSearchQueryAnd ?: JsonField.of(mutableListOf())).also { + checkKnown("notSearchQueryAnd", it).add(notSearchQueryAnd) + } + } + + fun notSearchQueryOr(notSearchQueryOr: List?) = + notSearchQueryOr(JsonField.ofNullable(notSearchQueryOr)) + + /** + * Alias for calling [Builder.notSearchQueryOr] with `notSearchQueryOr.orElse(null)`. + */ + fun notSearchQueryOr(notSearchQueryOr: Optional>) = + notSearchQueryOr(notSearchQueryOr.getOrNull()) + + /** + * Sets [Builder.notSearchQueryOr] to an arbitrary JSON value. + * + * You should usually call [Builder.notSearchQueryOr] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun notSearchQueryOr(notSearchQueryOr: JsonField>) = apply { + this.notSearchQueryOr = notSearchQueryOr.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.notSearchQueryOr]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNotSearchQueryOr(notSearchQueryOr: String) = apply { + this.notSearchQueryOr = + (this.notSearchQueryOr ?: JsonField.of(mutableListOf())).also { + checkKnown("notSearchQueryOr", it).add(notSearchQueryOr) + } + } + + fun rowIdList(rowIdList: List?) = rowIdList(JsonField.ofNullable(rowIdList)) + + /** Alias for calling [Builder.rowIdList] with `rowIdList.orElse(null)`. */ + fun rowIdList(rowIdList: Optional>) = rowIdList(rowIdList.getOrNull()) + + /** + * Sets [Builder.rowIdList] to an arbitrary JSON value. + * + * You should usually call [Builder.rowIdList] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rowIdList(rowIdList: JsonField>) = apply { + this.rowIdList = rowIdList.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.rowIdList]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRowIdList(rowIdList: Long) = apply { + this.rowIdList = + (this.rowIdList ?: JsonField.of(mutableListOf())).also { + checkKnown("rowIdList", it).add(rowIdList) + } + } + + fun searchQueryAnd(searchQueryAnd: List?) = + searchQueryAnd(JsonField.ofNullable(searchQueryAnd)) + + /** Alias for calling [Builder.searchQueryAnd] with `searchQueryAnd.orElse(null)`. */ + fun searchQueryAnd(searchQueryAnd: Optional>) = + searchQueryAnd(searchQueryAnd.getOrNull()) + + /** + * Sets [Builder.searchQueryAnd] to an arbitrary JSON value. + * + * You should usually call [Builder.searchQueryAnd] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun searchQueryAnd(searchQueryAnd: JsonField>) = apply { + this.searchQueryAnd = searchQueryAnd.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.searchQueryAnd]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSearchQueryAnd(searchQueryAnd: String) = apply { + this.searchQueryAnd = + (this.searchQueryAnd ?: JsonField.of(mutableListOf())).also { + checkKnown("searchQueryAnd", it).add(searchQueryAnd) + } + } + + fun searchQueryOr(searchQueryOr: List?) = + searchQueryOr(JsonField.ofNullable(searchQueryOr)) + + /** Alias for calling [Builder.searchQueryOr] with `searchQueryOr.orElse(null)`. */ + fun searchQueryOr(searchQueryOr: Optional>) = + searchQueryOr(searchQueryOr.getOrNull()) + + /** + * Sets [Builder.searchQueryOr] to an arbitrary JSON value. + * + * You should usually call [Builder.searchQueryOr] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun searchQueryOr(searchQueryOr: JsonField>) = apply { + this.searchQueryOr = searchQueryOr.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.searchQueryOr]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSearchQueryOr(searchQueryOr: String) = apply { + this.searchQueryOr = + (this.searchQueryOr ?: JsonField.of(mutableListOf())).also { + checkKnown("searchQueryOr", it).add(searchQueryOr) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (columnFilters ?: JsonMissing.of()).map { it.toImmutable() }, + (excludeRowIdList ?: JsonMissing.of()).map { it.toImmutable() }, + (notSearchQueryAnd ?: JsonMissing.of()).map { it.toImmutable() }, + (notSearchQueryOr ?: JsonMissing.of()).map { it.toImmutable() }, + (rowIdList ?: JsonMissing.of()).map { it.toImmutable() }, + (searchQueryAnd ?: JsonMissing.of()).map { it.toImmutable() }, + (searchQueryOr ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + columnFilters().ifPresent { it.forEach { it.validate() } } + excludeRowIdList() + notSearchQueryAnd() + notSearchQueryOr() + rowIdList() + searchQueryAnd() + searchQueryOr() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (columnFilters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (excludeRowIdList.asKnown().getOrNull()?.size ?: 0) + + (notSearchQueryAnd.asKnown().getOrNull()?.size ?: 0) + + (notSearchQueryOr.asKnown().getOrNull()?.size ?: 0) + + (rowIdList.asKnown().getOrNull()?.size ?: 0) + + (searchQueryAnd.asKnown().getOrNull()?.size ?: 0) + + (searchQueryOr.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + columnFilters == other.columnFilters && + excludeRowIdList == other.excludeRowIdList && + notSearchQueryAnd == other.notSearchQueryAnd && + notSearchQueryOr == other.notSearchQueryOr && + rowIdList == other.rowIdList && + searchQueryAnd == other.searchQueryAnd && + searchQueryOr == other.searchQueryOr && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + columnFilters, + excludeRowIdList, + notSearchQueryAnd, + notSearchQueryOr, + rowIdList, + searchQueryAnd, + searchQueryOr, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{columnFilters=$columnFilters, excludeRowIdList=$excludeRowIdList, notSearchQueryAnd=$notSearchQueryAnd, notSearchQueryOr=$notSearchQueryOr, rowIdList=$rowIdList, searchQueryAnd=$searchQueryAnd, searchQueryOr=$searchQueryOr, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = ColumnFilter.Deserializer::class) + @JsonSerialize(using = ColumnFilter.Serializer::class) + class ColumnFilter + private constructor( + private val set: SetColumnFilter? = null, + private val numeric: NumericColumnFilter? = null, + private val string: StringColumnFilter? = null, + private val _json: JsonValue? = null, + ) { + + fun set(): Optional = Optional.ofNullable(set) + + fun numeric(): Optional = Optional.ofNullable(numeric) + + fun string(): Optional = Optional.ofNullable(string) + + fun isSet(): Boolean = set != null + + fun isNumeric(): Boolean = numeric != null + + fun isString(): Boolean = string != null + + fun asSet(): SetColumnFilter = set.getOrThrow("set") + + fun asNumeric(): NumericColumnFilter = numeric.getOrThrow("numeric") + + fun asString(): StringColumnFilter = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + set != null -> visitor.visitSet(set) + numeric != null -> visitor.visitNumeric(numeric) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ColumnFilter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSet(set: SetColumnFilter) { + set.validate() + } + + override fun visitNumeric(numeric: NumericColumnFilter) { + numeric.validate() + } + + override fun visitString(string: StringColumnFilter) { + string.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSet(set: SetColumnFilter) = set.validity() + + override fun visitNumeric(numeric: NumericColumnFilter) = numeric.validity() + + override fun visitString(string: StringColumnFilter) = string.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ColumnFilter && + set == other.set && + numeric == other.numeric && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(set, numeric, string) + + override fun toString(): String = + when { + set != null -> "ColumnFilter{set=$set}" + numeric != null -> "ColumnFilter{numeric=$numeric}" + string != null -> "ColumnFilter{string=$string}" + _json != null -> "ColumnFilter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ColumnFilter") + } + + companion object { + + @JvmStatic fun ofSet(set: SetColumnFilter) = ColumnFilter(set = set) + + @JvmStatic fun ofNumeric(numeric: NumericColumnFilter) = ColumnFilter(numeric = numeric) + + @JvmStatic fun ofString(string: StringColumnFilter) = ColumnFilter(string = string) + } + + /** + * An interface that defines how to map each variant of [ColumnFilter] to a value of type + * [T]. + */ + interface Visitor { + + fun visitSet(set: SetColumnFilter): T + + fun visitNumeric(numeric: NumericColumnFilter): T + + fun visitString(string: StringColumnFilter): T + + /** + * Maps an unknown variant of [ColumnFilter] to a value of type [T]. + * + * An instance of [ColumnFilter] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenlayerInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenlayerInvalidDataException("Unknown ColumnFilter: $json") + } + } + + internal class Deserializer : BaseDeserializer(ColumnFilter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ColumnFilter { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ColumnFilter(set = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ColumnFilter(numeric = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ColumnFilter(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> ColumnFilter(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ColumnFilter::class) { + + override fun serialize( + value: ColumnFilter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.set != null -> generator.writeObject(value.set) + value.numeric != null -> generator.writeObject(value.numeric) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ColumnFilter") + } + } + } + + class SetColumnFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val measurement: JsonField, + private val operator: JsonField, + private val value: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("measurement") + @ExcludeMissing + measurement: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField> = JsonMissing.of(), + ) : this(measurement, operator, value, mutableMapOf()) + + /** + * The name of the column. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun measurement(): String = measurement.getRequired("measurement") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): List = value.getRequired("value") + + /** + * Returns the raw JSON value of [measurement]. + * + * Unlike [measurement], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("measurement") + @ExcludeMissing + fun _measurement(): JsonField = measurement + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField> = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SetColumnFilter]. + * + * The following fields are required: + * ```java + * .measurement() + * .operator() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SetColumnFilter]. */ + class Builder internal constructor() { + + private var measurement: JsonField? = null + private var operator: JsonField? = null + private var value: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(setColumnFilter: SetColumnFilter) = apply { + measurement = setColumnFilter.measurement + operator = setColumnFilter.operator + value = setColumnFilter.value.map { it.toMutableList() } + additionalProperties = setColumnFilter.additionalProperties.toMutableMap() + } + + /** The name of the column. */ + fun measurement(measurement: String) = measurement(JsonField.of(measurement)) + + /** + * Sets [Builder.measurement] to an arbitrary JSON value. + * + * You should usually call [Builder.measurement] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun measurement(measurement: JsonField) = apply { + this.measurement = measurement + } + + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun value(value: List) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun value(value: JsonField>) = apply { + this.value = value.map { it.toMutableList() } + } + + /** + * Adds a single [Value] to [Builder.value]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addValue(value: Value) = apply { + this.value = + (this.value ?: JsonField.of(mutableListOf())).also { + checkKnown("value", it).add(value) + } + } + + /** Alias for calling [addValue] with `Value.ofString(string)`. */ + fun addValue(string: String) = addValue(Value.ofString(string)) + + /** Alias for calling [addValue] with `Value.ofNumber(number)`. */ + fun addValue(number: Double) = addValue(Value.ofNumber(number)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SetColumnFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .measurement() + * .operator() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SetColumnFilter = + SetColumnFilter( + checkRequired("measurement", measurement), + checkRequired("operator", operator), + checkRequired("value", value).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SetColumnFilter = apply { + if (validated) { + return@apply + } + + measurement() + operator().validate() + value().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (measurement.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CONTAINS_NONE = of("contains_none") + + @JvmField val CONTAINS_ANY = of("contains_any") + + @JvmField val CONTAINS_ALL = of("contains_all") + + @JvmField val ONE_OF = of("one_of") + + @JvmField val NONE_OF = of("none_of") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + CONTAINS_NONE, + CONTAINS_ANY, + CONTAINS_ALL, + ONE_OF, + NONE_OF, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CONTAINS_NONE, + CONTAINS_ANY, + CONTAINS_ALL, + ONE_OF, + NONE_OF, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CONTAINS_NONE -> Value.CONTAINS_NONE + CONTAINS_ANY -> Value.CONTAINS_ANY + CONTAINS_ALL -> Value.CONTAINS_ALL + ONE_OF -> Value.ONE_OF + NONE_OF -> Value.NONE_OF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CONTAINS_NONE -> Known.CONTAINS_NONE + CONTAINS_ANY -> Known.CONTAINS_ANY + CONTAINS_ALL -> Known.CONTAINS_ALL + ONE_OF -> Known.ONE_OF + NONE_OF -> Known.NONE_OF + else -> throw OpenlayerInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && string == other.string && number == other.number + } + + override fun hashCode(): Int = Objects.hash(string, number) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + number != null -> "Value{number=$number}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + } + + /** + * An interface that defines how to map each variant of [Value] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws OpenlayerInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenlayerInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SetColumnFilter && + measurement == other.measurement && + operator == other.operator && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(measurement, operator, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SetColumnFilter{measurement=$measurement, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + } + + class NumericColumnFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val measurement: JsonField, + private val operator: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("measurement") + @ExcludeMissing + measurement: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(measurement, operator, value, mutableMapOf()) + + /** + * The name of the column. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun measurement(): String = measurement.getRequired("measurement") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [measurement]. + * + * Unlike [measurement], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("measurement") + @ExcludeMissing + fun _measurement(): JsonField = measurement + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NumericColumnFilter]. + * + * The following fields are required: + * ```java + * .measurement() + * .operator() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NumericColumnFilter]. */ + class Builder internal constructor() { + + private var measurement: JsonField? = null + private var operator: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(numericColumnFilter: NumericColumnFilter) = apply { + measurement = numericColumnFilter.measurement + operator = numericColumnFilter.operator + value = numericColumnFilter.value + additionalProperties = numericColumnFilter.additionalProperties.toMutableMap() + } + + /** The name of the column. */ + fun measurement(measurement: String) = measurement(JsonField.of(measurement)) + + /** + * Sets [Builder.measurement] to an arbitrary JSON value. + * + * You should usually call [Builder.measurement] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun measurement(measurement: JsonField) = apply { + this.measurement = measurement + } + + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun value(value: Float?) = value(JsonField.ofNullable(value)) + + /** + * Alias for [Builder.value]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun value(value: Float) = value(value as Float?) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NumericColumnFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .measurement() + * .operator() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NumericColumnFilter = + NumericColumnFilter( + checkRequired("measurement", measurement), + checkRequired("operator", operator), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NumericColumnFilter = apply { + if (validated) { + return@apply + } + + measurement() + operator().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (measurement.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GREATER = of(">") + + @JvmField val GREATER_OR_EQUALS = of(">=") + + @JvmField val IS = of("is") + + @JvmField val LESS = of("<") + + @JvmField val LESS_OR_EQUALS = of("<=") + + @JvmField val NOT_EQUALS = of("!=") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + GREATER, + GREATER_OR_EQUALS, + IS, + LESS, + LESS_OR_EQUALS, + NOT_EQUALS, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GREATER, + GREATER_OR_EQUALS, + IS, + LESS, + LESS_OR_EQUALS, + NOT_EQUALS, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GREATER -> Value.GREATER + GREATER_OR_EQUALS -> Value.GREATER_OR_EQUALS + IS -> Value.IS + LESS -> Value.LESS + LESS_OR_EQUALS -> Value.LESS_OR_EQUALS + NOT_EQUALS -> Value.NOT_EQUALS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GREATER -> Known.GREATER + GREATER_OR_EQUALS -> Known.GREATER_OR_EQUALS + IS -> Known.IS + LESS -> Known.LESS + LESS_OR_EQUALS -> Known.LESS_OR_EQUALS + NOT_EQUALS -> Known.NOT_EQUALS + else -> throw OpenlayerInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NumericColumnFilter && + measurement == other.measurement && + operator == other.operator && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(measurement, operator, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NumericColumnFilter{measurement=$measurement, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + } + + class StringColumnFilter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val measurement: JsonField, + private val operator: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("measurement") + @ExcludeMissing + measurement: JsonField = JsonMissing.of(), + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(measurement, operator, value, mutableMapOf()) + + /** + * The name of the column. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun measurement(): String = measurement.getRequired("measurement") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): Value = value.getRequired("value") + + /** + * Returns the raw JSON value of [measurement]. + * + * Unlike [measurement], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("measurement") + @ExcludeMissing + fun _measurement(): JsonField = measurement + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [StringColumnFilter]. + * + * The following fields are required: + * ```java + * .measurement() + * .operator() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StringColumnFilter]. */ + class Builder internal constructor() { + + private var measurement: JsonField? = null + private var operator: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(stringColumnFilter: StringColumnFilter) = apply { + measurement = stringColumnFilter.measurement + operator = stringColumnFilter.operator + value = stringColumnFilter.value + additionalProperties = stringColumnFilter.additionalProperties.toMutableMap() + } + + /** The name of the column. */ + fun measurement(measurement: String) = measurement(JsonField.of(measurement)) + + /** + * Sets [Builder.measurement] to an arbitrary JSON value. + * + * You should usually call [Builder.measurement] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun measurement(measurement: JsonField) = apply { + this.measurement = measurement + } + + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun value(value: Value) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [StringColumnFilter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .measurement() + * .operator() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StringColumnFilter = + StringColumnFilter( + checkRequired("measurement", measurement), + checkRequired("operator", operator), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StringColumnFilter = apply { + if (validated) { + return@apply + } + + measurement() + operator().validate() + value().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (measurement.asKnown().isPresent) 1 else 0) + + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IS = of("is") + + @JvmField val NOT_EQUALS = of("!=") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + IS, + NOT_EQUALS, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IS, + NOT_EQUALS, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IS -> Value.IS + NOT_EQUALS -> Value.NOT_EQUALS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + IS -> Known.IS + NOT_EQUALS -> Known.NOT_EQUALS + else -> throw OpenlayerInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Value = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Value && string == other.string && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, bool) + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + bool != null -> "Value{bool=$bool}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) + } + + /** + * An interface that defines how to map each variant of [Value] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws OpenlayerInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenlayerInvalidDataException("Unknown Value: $json") + } + } + + internal class Deserializer : BaseDeserializer(Value::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // integer). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is StringColumnFilter && + measurement == other.measurement && + operator == other.operator && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(measurement, operator, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StringColumnFilter{measurement=$measurement, operator=$operator, value=$value, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RowListParams && + inferencePipelineId == other.inferencePipelineId && + asc == other.asc && + page == other.page && + perPage == other.perPage && + sortColumn == other.sortColumn && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + inferencePipelineId, + asc, + page, + perPage, + sortColumn, + body, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "RowListParams{inferencePipelineId=$inferencePipelineId, asc=$asc, page=$page, perPage=$perPage, sortColumn=$sortColumn, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListResponse.kt new file mode 100644 index 00000000..f443821e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListResponse.kt @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class RowListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RowListResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RowListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rowListResponse: RowListResponse) = apply { + items = rowListResponse.items.map { it.toMutableList() } + additionalProperties = rowListResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RowListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RowListResponse = + RowListResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RowListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val openlayerRowId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("openlayer_row_id") + @ExcludeMissing + openlayerRowId: JsonField = JsonMissing.of() + ) : this(openlayerRowId, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun openlayerRowId(): Long = openlayerRowId.getRequired("openlayer_row_id") + + /** + * Returns the raw JSON value of [openlayerRowId]. + * + * Unlike [openlayerRowId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("openlayer_row_id") + @ExcludeMissing + fun _openlayerRowId(): JsonField = openlayerRowId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .openlayerRowId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var openlayerRowId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + openlayerRowId = item.openlayerRowId + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun openlayerRowId(openlayerRowId: Long) = openlayerRowId(JsonField.of(openlayerRowId)) + + /** + * Sets [Builder.openlayerRowId] to an arbitrary JSON value. + * + * You should usually call [Builder.openlayerRowId] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun openlayerRowId(openlayerRowId: JsonField) = apply { + this.openlayerRowId = openlayerRowId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .openlayerRowId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("openlayerRowId", openlayerRowId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + openlayerRowId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (openlayerRowId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + openlayerRowId == other.openlayerRowId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(openlayerRowId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{openlayerRowId=$openlayerRowId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RowListResponse && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RowListResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt index 89429640..e999e050 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsync.kt @@ -5,6 +5,8 @@ package com.openlayer.api.services.async.inferencepipelines import com.openlayer.api.core.ClientOptions import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.rows.RowListParams +import com.openlayer.api.models.inferencepipelines.rows.RowListResponse import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse import java.util.concurrent.CompletableFuture @@ -49,6 +51,41 @@ interface RowServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** A list of rows for an inference pipeline. */ + fun list(inferencePipelineId: String): CompletableFuture = + list(inferencePipelineId, RowListParams.none()) + + /** @see list */ + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().inferencePipelineId(inferencePipelineId).build(), requestOptions) + + /** @see list */ + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + ): CompletableFuture = list(inferencePipelineId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RowListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list(params: RowListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(inferencePipelineId, RowListParams.none(), requestOptions) + /** A view of [RowServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -89,5 +126,47 @@ interface RowServiceAsync { params: RowUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /inference-pipelines/{inferencePipelineId}/rows`, + * but is otherwise the same as [RowServiceAsync.list]. + */ + fun list(inferencePipelineId: String): CompletableFuture> = + list(inferencePipelineId, RowListParams.none()) + + /** @see list */ + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list( + params.toBuilder().inferencePipelineId(inferencePipelineId).build(), + requestOptions, + ) + + /** @see list */ + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + ): CompletableFuture> = + list(inferencePipelineId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RowListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list(params: RowListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(inferencePipelineId, RowListParams.none(), requestOptions) } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt index 52a56074..d6acb5ec 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt @@ -16,6 +16,8 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.inferencepipelines.rows.RowListParams +import com.openlayer.api.models.inferencepipelines.rows.RowListResponse import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse import java.util.concurrent.CompletableFuture @@ -41,6 +43,13 @@ class RowServiceAsyncImpl internal constructor(private val clientOptions: Client // put /inference-pipelines/{inferencePipelineId}/rows withRawResponse().update(params, requestOptions).thenApply { it.parse() } + override fun list( + params: RowListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /inference-pipelines/{inferencePipelineId}/rows + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RowServiceAsync.WithRawResponse { @@ -87,5 +96,39 @@ class RowServiceAsyncImpl internal constructor(private val clientOptions: Client } } } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: RowListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("inferencePipelineId", params.inferencePipelineId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("inference-pipelines", params._pathParam(0), "rows") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt index 506a14c5..527bb229 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowService.kt @@ -6,6 +6,8 @@ import com.google.errorprone.annotations.MustBeClosed import com.openlayer.api.core.ClientOptions import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.inferencepipelines.rows.RowListParams +import com.openlayer.api.models.inferencepipelines.rows.RowListResponse import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse import java.util.function.Consumer @@ -45,6 +47,37 @@ interface RowService { requestOptions: RequestOptions = RequestOptions.none(), ): RowUpdateResponse + /** A list of rows for an inference pipeline. */ + fun list(inferencePipelineId: String): RowListResponse = + list(inferencePipelineId, RowListParams.none()) + + /** @see list */ + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): RowListResponse = + list(params.toBuilder().inferencePipelineId(inferencePipelineId).build(), requestOptions) + + /** @see list */ + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + ): RowListResponse = list(inferencePipelineId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: RowListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): RowListResponse + + /** @see list */ + fun list(params: RowListParams): RowListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(inferencePipelineId: String, requestOptions: RequestOptions): RowListResponse = + list(inferencePipelineId, RowListParams.none(), requestOptions) + /** A view of [RowService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -89,5 +122,53 @@ interface RowService { params: RowUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /inference-pipelines/{inferencePipelineId}/rows`, + * but is otherwise the same as [RowService.list]. + */ + @MustBeClosed + fun list(inferencePipelineId: String): HttpResponseFor = + list(inferencePipelineId, RowListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list( + params.toBuilder().inferencePipelineId(inferencePipelineId).build(), + requestOptions, + ) + + /** @see list */ + @MustBeClosed + fun list( + inferencePipelineId: String, + params: RowListParams = RowListParams.none(), + ): HttpResponseFor = + list(inferencePipelineId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: RowListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: RowListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(inferencePipelineId, RowListParams.none(), requestOptions) } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt index 28e65ad3..005c081d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt @@ -16,6 +16,8 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare +import com.openlayer.api.models.inferencepipelines.rows.RowListParams +import com.openlayer.api.models.inferencepipelines.rows.RowListResponse import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse import java.util.function.Consumer @@ -39,6 +41,10 @@ class RowServiceImpl internal constructor(private val clientOptions: ClientOptio // put /inference-pipelines/{inferencePipelineId}/rows withRawResponse().update(params, requestOptions).parse() + override fun list(params: RowListParams, requestOptions: RequestOptions): RowListResponse = + // post /inference-pipelines/{inferencePipelineId}/rows + withRawResponse().list(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RowService.WithRawResponse { @@ -82,5 +88,36 @@ class RowServiceImpl internal constructor(private val clientOptions: ClientOptio } } } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: RowListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("inferencePipelineId", params.inferencePipelineId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("inference-pipelines", params._pathParam(0), "rows") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListParamsTest.kt new file mode 100644 index 00000000..4ea871f5 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListParamsTest.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +import com.openlayer.api.core.http.QueryParams +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RowListParamsTest { + + @Test + fun create() { + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + RowListParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator(RowListParams.ColumnFilter.SetColumnFilter.Operator.CONTAINS_NONE) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + } + + @Test + fun pathParams() { + val params = + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + RowListParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator(RowListParams.ColumnFilter.SetColumnFilter.Operator.CONTAINS_NONE) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("asc", "true") + .put("page", "1") + .put("perPage", "1") + .put("sortColumn", "sortColumn") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + RowListParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator(RowListParams.ColumnFilter.SetColumnFilter.Operator.CONTAINS_NONE) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + + val body = params._body() + + assertThat(body.columnFilters().getOrNull()) + .containsExactly( + RowListParams.ColumnFilter.ofSet( + RowListParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator(RowListParams.ColumnFilter.SetColumnFilter.Operator.CONTAINS_NONE) + .addValue("cat") + .build() + ) + ) + assertThat(body.excludeRowIdList().getOrNull()).containsExactly(0L) + assertThat(body.notSearchQueryAnd().getOrNull()).containsExactly("string") + assertThat(body.notSearchQueryOr().getOrNull()).containsExactly("string") + assertThat(body.rowIdList().getOrNull()).containsExactly(0L) + assertThat(body.searchQueryAnd().getOrNull()).containsExactly("string") + assertThat(body.searchQueryOr().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListResponseTest.kt new file mode 100644 index 00000000..9a6506f5 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowListResponseTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines.rows + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RowListResponseTest { + + @Test + fun create() { + val rowListResponse = + RowListResponse.builder() + .addItem(RowListResponse.Item.builder().openlayerRowId(0L).build()) + .build() + + assertThat(rowListResponse.items()) + .containsExactly(RowListResponse.Item.builder().openlayerRowId(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rowListResponse = + RowListResponse.builder() + .addItem(RowListResponse.Item.builder().openlayerRowId(0L).build()) + .build() + + val roundtrippedRowListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rowListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRowListResponse).isEqualTo(rowListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt index 832ac384..f678b40a 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.openlayer.api.services.async.inferencepipelines import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.inferencepipelines.rows.RowListParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -42,4 +43,43 @@ internal class RowServiceAsyncTest { val row = rowFuture.get() row.validate() } + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val rowServiceAsync = client.inferencePipelines().rows() + + val rowsFuture = + rowServiceAsync.list( + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + RowListParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + RowListParams.ColumnFilter.SetColumnFilter.Operator.CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + ) + + val rows = rowsFuture.get() + rows.validate() + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt index 0988b2e1..7745e1e0 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceTest.kt @@ -5,6 +5,7 @@ package com.openlayer.api.services.blocking.inferencepipelines import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.inferencepipelines.rows.RowListParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -41,4 +42,42 @@ internal class RowServiceTest { row.validate() } + + @Test + fun list() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val rowService = client.inferencePipelines().rows() + + val rows = + rowService.list( + RowListParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + RowListParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + RowListParams.ColumnFilter.SetColumnFilter.Operator.CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + ) + + rows.validate() + } } diff --git a/scripts/mock b/scripts/mock index 0b28f6ea..bcf3b392 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,11 +21,22 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - # Wait for server to come online + # Wait for server to come online (max 30s) echo -n "Waiting for server" + attempts=0 while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Prism server to start" + cat .prism.log + exit 1 + fi echo -n "." sleep 0.1 done