diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1b77f506..6538ca91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.7.0" + ".": "0.8.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a47d0ba9..9f47e6b1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,3 +1,3 @@ -configured_endpoints: 28 -openapi_spec_hash: 5f7962599290c70cb47c05c3b29fdbd8 -config_hash: f1c0c034bd832878eb47146c51afdd55 +configured_endpoints: 29 +openapi_spec_hash: 20caa671b1b1a87c0a5cb6ebd7e4b064 +config_hash: aaf12ae1da71c62ca5195fc2b66f657c diff --git a/CHANGELOG.md b/CHANGELOG.md index 8698bbbf..864f4153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.8.0 (2026-04-01) + +Full Changelog: [v0.7.0...v0.8.0](https://github.com/openlayer-ai/openlayer-java/compare/v0.7.0...v0.8.0) + +### Features + +* Cid/fetching endpoints ([5efb36f](https://github.com/openlayer-ai/openlayer-java/commit/5efb36f68fc0db96132ce01bb61f43fb469f2b6e)) + ## 0.7.0 (2026-04-01) Full Changelog: [v0.6.2...v0.7.0](https://github.com/openlayer-ai/openlayer-java/compare/v0.6.2...v0.7.0) diff --git a/README.md b/README.md index 452ec589..cdf76135 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.7.0) -[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.7.0/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.7.0) +[![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.8.0) +[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.8.0/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.8.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.7.0). +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.8.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.7.0") +implementation("com.openlayer.api:openlayer-java:0.8.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openlayer.api:openlayer-java:0.7.0") com.openlayer.api openlayer-java - 0.7.0 + 0.8.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index a6d7970e..d9c835a7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openlayer.api" - version = "0.7.0" // x-release-please-version + version = "0.8.0" // x-release-please-version } subprojects { diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsParams.kt new file mode 100644 index 00000000..09018b1e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsParams.kt @@ -0,0 +1,2971 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.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 + +/** + * Get aggregated session data for an inference pipeline with pagination and metadata. + * + * Returns a list of sessions for the inference pipeline, including activity statistics such as + * record counts, token usage, cost, latency, and the first and last records. + */ +class InferencePipelineRetrieveSessionsParams +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(): InferencePipelineRetrieveSessionsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [InferencePipelineRetrieveSessionsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineRetrieveSessionsParams]. */ + 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( + inferencePipelineRetrieveSessionsParams: InferencePipelineRetrieveSessionsParams + ) = apply { + inferencePipelineId = inferencePipelineRetrieveSessionsParams.inferencePipelineId + asc = inferencePipelineRetrieveSessionsParams.asc + page = inferencePipelineRetrieveSessionsParams.page + perPage = inferencePipelineRetrieveSessionsParams.perPage + sortColumn = inferencePipelineRetrieveSessionsParams.sortColumn + body = inferencePipelineRetrieveSessionsParams.body.toBuilder() + additionalHeaders = + inferencePipelineRetrieveSessionsParams.additionalHeaders.toBuilder() + additionalQueryParams = + inferencePipelineRetrieveSessionsParams.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 [InferencePipelineRetrieveSessionsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams( + 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 InferencePipelineRetrieveSessionsParams && + 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() = + "InferencePipelineRetrieveSessionsParams{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/InferencePipelineRetrieveSessionsResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsResponse.kt new file mode 100644 index 00000000..55c201d9 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsResponse.kt @@ -0,0 +1,1050 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class InferencePipelineRetrieveSessionsResponse +@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()) + + /** + * Array of session aggregation data + * + * @throws OpenlayerInvalidDataException if 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 + * [InferencePipelineRetrieveSessionsResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InferencePipelineRetrieveSessionsResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + inferencePipelineRetrieveSessionsResponse: InferencePipelineRetrieveSessionsResponse + ) = apply { + items = inferencePipelineRetrieveSessionsResponse.items.map { it.toMutableList() } + additionalProperties = + inferencePipelineRetrieveSessionsResponse.additionalProperties.toMutableMap() + } + + /** Array of session aggregation data */ + 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 [InferencePipelineRetrieveSessionsResponse]. + * + * 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(): InferencePipelineRetrieveSessionsResponse = + InferencePipelineRetrieveSessionsResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InferencePipelineRetrieveSessionsResponse = 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 id: JsonField, + private val cost: JsonField, + private val dateCreated: JsonField, + private val dateOfFirstRecord: JsonField, + private val dateOfLastRecord: JsonField, + private val duration: JsonField, + private val firstRecord: JsonField, + private val lastRecord: JsonField, + private val latency: JsonField, + private val records: JsonField, + private val tokens: JsonField, + private val userIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("cost") @ExcludeMissing cost: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateOfFirstRecord") + @ExcludeMissing + dateOfFirstRecord: JsonField = JsonMissing.of(), + @JsonProperty("dateOfLastRecord") + @ExcludeMissing + dateOfLastRecord: JsonField = JsonMissing.of(), + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("firstRecord") + @ExcludeMissing + firstRecord: JsonField = JsonMissing.of(), + @JsonProperty("lastRecord") + @ExcludeMissing + lastRecord: JsonField = JsonMissing.of(), + @JsonProperty("latency") @ExcludeMissing latency: JsonField = JsonMissing.of(), + @JsonProperty("records") @ExcludeMissing records: JsonField = JsonMissing.of(), + @JsonProperty("tokens") @ExcludeMissing tokens: JsonField = JsonMissing.of(), + @JsonProperty("userIds") + @ExcludeMissing + userIds: JsonField> = JsonMissing.of(), + ) : this( + id, + cost, + dateCreated, + dateOfFirstRecord, + dateOfLastRecord, + duration, + firstRecord, + lastRecord, + latency, + records, + tokens, + userIds, + mutableMapOf(), + ) + + /** + * The unique session identifier + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Total cost for the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cost(): Float = cost.getRequired("cost") + + /** + * Latest/most recent timestamp in the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * Timestamp of the first request in the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateOfFirstRecord(): OffsetDateTime = dateOfFirstRecord.getRequired("dateOfFirstRecord") + + /** + * Timestamp of the last request in the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateOfLastRecord(): OffsetDateTime = dateOfLastRecord.getRequired("dateOfLastRecord") + + /** + * Duration between first and last request (in milliseconds) + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun duration(): Float = duration.getRequired("duration") + + /** + * The complete first record in the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun firstRecord(): FirstRecord = firstRecord.getRequired("firstRecord") + + /** + * The complete last record in the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lastRecord(): LastRecord = lastRecord.getRequired("lastRecord") + + /** + * Total latency for the session (in milliseconds) + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun latency(): Float = latency.getRequired("latency") + + /** + * Total number of records/traces in the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun records(): Long = records.getRequired("records") + + /** + * Total token count for the session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokens(): Float = tokens.getRequired("tokens") + + /** + * List of unique user IDs that participated in this session + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userIds(): List = userIds.getRequired("userIds") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [cost]. + * + * Unlike [cost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost") @ExcludeMissing fun _cost(): JsonField = cost + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateOfFirstRecord]. + * + * Unlike [dateOfFirstRecord], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateOfFirstRecord") + @ExcludeMissing + fun _dateOfFirstRecord(): JsonField = dateOfFirstRecord + + /** + * Returns the raw JSON value of [dateOfLastRecord]. + * + * Unlike [dateOfLastRecord], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateOfLastRecord") + @ExcludeMissing + fun _dateOfLastRecord(): JsonField = dateOfLastRecord + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [firstRecord]. + * + * Unlike [firstRecord], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("firstRecord") + @ExcludeMissing + fun _firstRecord(): JsonField = firstRecord + + /** + * Returns the raw JSON value of [lastRecord]. + * + * Unlike [lastRecord], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lastRecord") + @ExcludeMissing + fun _lastRecord(): JsonField = lastRecord + + /** + * Returns the raw JSON value of [latency]. + * + * Unlike [latency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency") @ExcludeMissing fun _latency(): JsonField = latency + + /** + * Returns the raw JSON value of [records]. + * + * Unlike [records], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("records") @ExcludeMissing fun _records(): JsonField = records + + /** + * Returns the raw JSON value of [tokens]. + * + * Unlike [tokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tokens") @ExcludeMissing fun _tokens(): JsonField = tokens + + /** + * Returns the raw JSON value of [userIds]. + * + * Unlike [userIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("userIds") @ExcludeMissing fun _userIds(): JsonField> = userIds + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .id() + * .cost() + * .dateCreated() + * .dateOfFirstRecord() + * .dateOfLastRecord() + * .duration() + * .firstRecord() + * .lastRecord() + * .latency() + * .records() + * .tokens() + * .userIds() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var cost: JsonField? = null + private var dateCreated: JsonField? = null + private var dateOfFirstRecord: JsonField? = null + private var dateOfLastRecord: JsonField? = null + private var duration: JsonField? = null + private var firstRecord: JsonField? = null + private var lastRecord: JsonField? = null + private var latency: JsonField? = null + private var records: JsonField? = null + private var tokens: JsonField? = null + private var userIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + cost = item.cost + dateCreated = item.dateCreated + dateOfFirstRecord = item.dateOfFirstRecord + dateOfLastRecord = item.dateOfLastRecord + duration = item.duration + firstRecord = item.firstRecord + lastRecord = item.lastRecord + latency = item.latency + records = item.records + tokens = item.tokens + userIds = item.userIds.map { it.toMutableList() } + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The unique session identifier */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Total cost for the session */ + fun cost(cost: Float) = cost(JsonField.of(cost)) + + /** + * Sets [Builder.cost] to an arbitrary JSON value. + * + * You should usually call [Builder.cost] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cost(cost: JsonField) = apply { this.cost = cost } + + /** Latest/most recent timestamp in the session */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** Timestamp of the first request in the session */ + fun dateOfFirstRecord(dateOfFirstRecord: OffsetDateTime) = + dateOfFirstRecord(JsonField.of(dateOfFirstRecord)) + + /** + * Sets [Builder.dateOfFirstRecord] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfFirstRecord] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dateOfFirstRecord(dateOfFirstRecord: JsonField) = apply { + this.dateOfFirstRecord = dateOfFirstRecord + } + + /** Timestamp of the last request in the session */ + fun dateOfLastRecord(dateOfLastRecord: OffsetDateTime) = + dateOfLastRecord(JsonField.of(dateOfLastRecord)) + + /** + * Sets [Builder.dateOfLastRecord] to an arbitrary JSON value. + * + * You should usually call [Builder.dateOfLastRecord] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateOfLastRecord(dateOfLastRecord: JsonField) = apply { + this.dateOfLastRecord = dateOfLastRecord + } + + /** Duration between first and last request (in milliseconds) */ + fun duration(duration: Float) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The complete first record in the session */ + fun firstRecord(firstRecord: FirstRecord) = firstRecord(JsonField.of(firstRecord)) + + /** + * Sets [Builder.firstRecord] to an arbitrary JSON value. + * + * You should usually call [Builder.firstRecord] with a well-typed [FirstRecord] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstRecord(firstRecord: JsonField) = apply { + this.firstRecord = firstRecord + } + + /** The complete last record in the session */ + fun lastRecord(lastRecord: LastRecord) = lastRecord(JsonField.of(lastRecord)) + + /** + * Sets [Builder.lastRecord] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRecord] with a well-typed [LastRecord] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastRecord(lastRecord: JsonField) = apply { + this.lastRecord = lastRecord + } + + /** Total latency for the session (in milliseconds) */ + fun latency(latency: Float) = latency(JsonField.of(latency)) + + /** + * Sets [Builder.latency] to an arbitrary JSON value. + * + * You should usually call [Builder.latency] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latency(latency: JsonField) = apply { this.latency = latency } + + /** Total number of records/traces in the session */ + fun records(records: Long) = records(JsonField.of(records)) + + /** + * Sets [Builder.records] to an arbitrary JSON value. + * + * You should usually call [Builder.records] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun records(records: JsonField) = apply { this.records = records } + + /** Total token count for the session */ + fun tokens(tokens: Float) = tokens(JsonField.of(tokens)) + + /** + * Sets [Builder.tokens] to an arbitrary JSON value. + * + * You should usually call [Builder.tokens] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokens(tokens: JsonField) = apply { this.tokens = tokens } + + /** List of unique user IDs that participated in this session */ + fun userIds(userIds: List) = userIds(JsonField.of(userIds)) + + /** + * Sets [Builder.userIds] to an arbitrary JSON value. + * + * You should usually call [Builder.userIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userIds(userIds: JsonField>) = apply { + this.userIds = userIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [userIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUserId(userId: String) = apply { + userIds = + (userIds ?: JsonField.of(mutableListOf())).also { + checkKnown("userIds", it).add(userId) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .cost() + * .dateCreated() + * .dateOfFirstRecord() + * .dateOfLastRecord() + * .duration() + * .firstRecord() + * .lastRecord() + * .latency() + * .records() + * .tokens() + * .userIds() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("cost", cost), + checkRequired("dateCreated", dateCreated), + checkRequired("dateOfFirstRecord", dateOfFirstRecord), + checkRequired("dateOfLastRecord", dateOfLastRecord), + checkRequired("duration", duration), + checkRequired("firstRecord", firstRecord), + checkRequired("lastRecord", lastRecord), + checkRequired("latency", latency), + checkRequired("records", records), + checkRequired("tokens", tokens), + checkRequired("userIds", userIds).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + cost() + dateCreated() + dateOfFirstRecord() + dateOfLastRecord() + duration() + firstRecord().validate() + lastRecord().validate() + latency() + records() + tokens() + userIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (cost.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateOfFirstRecord.asKnown().isPresent) 1 else 0) + + (if (dateOfLastRecord.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (firstRecord.asKnown().getOrNull()?.validity() ?: 0) + + (lastRecord.asKnown().getOrNull()?.validity() ?: 0) + + (if (latency.asKnown().isPresent) 1 else 0) + + (if (records.asKnown().isPresent) 1 else 0) + + (if (tokens.asKnown().isPresent) 1 else 0) + + (userIds.asKnown().getOrNull()?.size ?: 0) + + /** The complete first record in the session */ + class FirstRecord + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FirstRecord]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FirstRecord]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(firstRecord: FirstRecord) = apply { + additionalProperties = firstRecord.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FirstRecord]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FirstRecord = FirstRecord(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): FirstRecord = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FirstRecord && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "FirstRecord{additionalProperties=$additionalProperties}" + } + + /** The complete last record in the session */ + class LastRecord + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LastRecord]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LastRecord]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(lastRecord: LastRecord) = apply { + additionalProperties = lastRecord.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LastRecord]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LastRecord = LastRecord(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): LastRecord = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LastRecord && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "LastRecord{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + id == other.id && + cost == other.cost && + dateCreated == other.dateCreated && + dateOfFirstRecord == other.dateOfFirstRecord && + dateOfLastRecord == other.dateOfLastRecord && + duration == other.duration && + firstRecord == other.firstRecord && + lastRecord == other.lastRecord && + latency == other.latency && + records == other.records && + tokens == other.tokens && + userIds == other.userIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + cost, + dateCreated, + dateOfFirstRecord, + dateOfLastRecord, + duration, + firstRecord, + lastRecord, + latency, + records, + tokens, + userIds, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, cost=$cost, dateCreated=$dateCreated, dateOfFirstRecord=$dateOfFirstRecord, dateOfLastRecord=$dateOfLastRecord, duration=$duration, firstRecord=$firstRecord, lastRecord=$lastRecord, latency=$latency, records=$records, tokens=$tokens, userIds=$userIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineRetrieveSessionsResponse && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InferencePipelineRetrieveSessionsResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParams.kt index 98206140..49eb7d3b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParams.kt @@ -2,9 +2,34 @@ package com.openlayer.api.models.inferencepipelines +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.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 @@ -18,20 +43,125 @@ import kotlin.jvm.optionals.getOrNull class InferencePipelineRetrieveUsersParams 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 @@ -55,8 +185,11 @@ private constructor( 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() @@ -65,8 +198,11 @@ private constructor( inferencePipelineRetrieveUsersParams: InferencePipelineRetrieveUsersParams ) = apply { inferencePipelineId = inferencePipelineRetrieveUsersParams.inferencePipelineId + asc = inferencePipelineRetrieveUsersParams.asc page = inferencePipelineRetrieveUsersParams.page perPage = inferencePipelineRetrieveUsersParams.perPage + sortColumn = inferencePipelineRetrieveUsersParams.sortColumn + body = inferencePipelineRetrieveUsersParams.body.toBuilder() additionalHeaders = inferencePipelineRetrieveUsersParams.additionalHeaders.toBuilder() additionalQueryParams = inferencePipelineRetrieveUsersParams.additionalQueryParams.toBuilder() @@ -82,6 +218,19 @@ private constructor( 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 } @@ -108,6 +257,245 @@ private constructor( /** 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) @@ -214,13 +602,18 @@ private constructor( fun build(): InferencePipelineRetrieveUsersParams = InferencePipelineRetrieveUsersParams( inferencePipelineId, + asc, page, perPage, + sortColumn, + body.build(), additionalHeaders.build(), additionalQueryParams.build(), ) } + fun _body(): Body = body + fun _pathParam(index: Int): String = when (index) { 0 -> inferencePipelineId ?: "" @@ -232,12 +625,2318 @@ private constructor( 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 @@ -245,15 +2944,27 @@ private constructor( return other is InferencePipelineRetrieveUsersParams && 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, page, perPage, additionalHeaders, additionalQueryParams) + Objects.hash( + inferencePipelineId, + asc, + page, + perPage, + sortColumn, + body, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "InferencePipelineRetrieveUsersParams{inferencePipelineId=$inferencePipelineId, page=$page, perPage=$perPage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InferencePipelineRetrieveUsersParams{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/services/async/InferencePipelineServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt index 03447cce..f0af2d5f 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt @@ -9,6 +9,8 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams @@ -154,6 +156,60 @@ interface InferencePipelineServiceAsync { ): CompletableFuture = delete(inferencePipelineId, InferencePipelineDeleteParams.none(), requestOptions) + /** + * Get aggregated session data for an inference pipeline with pagination and metadata. + * + * Returns a list of sessions for the inference pipeline, including activity statistics such as + * record counts, token usage, cost, latency, and the first and last records. + */ + fun retrieveSessions( + inferencePipelineId: String + ): CompletableFuture = + retrieveSessions(inferencePipelineId, InferencePipelineRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveSessions( + params.toBuilder().inferencePipelineId(inferencePipelineId).build(), + requestOptions, + ) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + ): CompletableFuture = + retrieveSessions(inferencePipelineId, params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveSessions */ + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams + ): CompletableFuture = + retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveSessions( + inferencePipelineId, + InferencePipelineRetrieveSessionsParams.none(), + requestOptions, + ) + /** * Get aggregated user data for an inference pipeline with pagination and metadata. * @@ -362,7 +418,60 @@ interface InferencePipelineServiceAsync { delete(inferencePipelineId, InferencePipelineDeleteParams.none(), requestOptions) /** - * Returns a raw HTTP response for `get /inference-pipelines/{inferencePipelineId}/users`, + * Returns a raw HTTP response for `post + * /inference-pipelines/{inferencePipelineId}/sessions`, but is otherwise the same as + * [InferencePipelineServiceAsync.retrieveSessions]. + */ + fun retrieveSessions( + inferencePipelineId: String + ): CompletableFuture> = + retrieveSessions(inferencePipelineId, InferencePipelineRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveSessions( + params.toBuilder().inferencePipelineId(inferencePipelineId).build(), + requestOptions, + ) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + ): CompletableFuture> = + retrieveSessions(inferencePipelineId, params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveSessions */ + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams + ): CompletableFuture> = + retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveSessions( + inferencePipelineId, + InferencePipelineRetrieveSessionsParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `post /inference-pipelines/{inferencePipelineId}/users`, * but is otherwise the same as [InferencePipelineServiceAsync.retrieveUsers]. */ fun retrieveUsers( diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt index cf74ffd7..5f60b51d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt @@ -20,6 +20,8 @@ import com.openlayer.api.core.prepareAsync import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams @@ -83,11 +85,18 @@ internal constructor(private val clientOptions: ClientOptions) : InferencePipeli // delete /inference-pipelines/{inferencePipelineId} withRawResponse().delete(params, requestOptions).thenAccept {} + override fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /inference-pipelines/{inferencePipelineId}/sessions + withRawResponse().retrieveSessions(params, requestOptions).thenApply { it.parse() } + override fun retrieveUsers( params: InferencePipelineRetrieveUsersParams, requestOptions: RequestOptions, ): CompletableFuture = - // get /inference-pipelines/{inferencePipelineId}/users + // post /inference-pipelines/{inferencePipelineId}/users withRawResponse().retrieveUsers(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -215,6 +224,40 @@ internal constructor(private val clientOptions: ClientOptions) : InferencePipeli } } + private val retrieveSessionsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + 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), "sessions") + .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 { retrieveSessionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val retrieveUsersHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -227,9 +270,10 @@ internal constructor(private val clientOptions: ClientOptions) : InferencePipeli checkRequired("inferencePipelineId", params.inferencePipelineId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.GET) + .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) .addPathSegments("inference-pipelines", params._pathParam(0), "users") + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt index ffffe91a..b30664fd 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt @@ -10,6 +10,8 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams @@ -143,6 +145,57 @@ interface InferencePipelineService { fun delete(inferencePipelineId: String, requestOptions: RequestOptions) = delete(inferencePipelineId, InferencePipelineDeleteParams.none(), requestOptions) + /** + * Get aggregated session data for an inference pipeline with pagination and metadata. + * + * Returns a list of sessions for the inference pipeline, including activity statistics such as + * record counts, token usage, cost, latency, and the first and last records. + */ + fun retrieveSessions(inferencePipelineId: String): InferencePipelineRetrieveSessionsResponse = + retrieveSessions(inferencePipelineId, InferencePipelineRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InferencePipelineRetrieveSessionsResponse = + retrieveSessions( + params.toBuilder().inferencePipelineId(inferencePipelineId).build(), + requestOptions, + ) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + ): InferencePipelineRetrieveSessionsResponse = + retrieveSessions(inferencePipelineId, params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InferencePipelineRetrieveSessionsResponse + + /** @see retrieveSessions */ + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams + ): InferencePipelineRetrieveSessionsResponse = retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + fun retrieveSessions( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): InferencePipelineRetrieveSessionsResponse = + retrieveSessions( + inferencePipelineId, + InferencePipelineRetrieveSessionsParams.none(), + requestOptions, + ) + /** * Get aggregated user data for an inference pipeline with pagination and metadata. * @@ -359,7 +412,66 @@ interface InferencePipelineService { delete(inferencePipelineId, InferencePipelineDeleteParams.none(), requestOptions) /** - * Returns a raw HTTP response for `get /inference-pipelines/{inferencePipelineId}/users`, + * Returns a raw HTTP response for `post + * /inference-pipelines/{inferencePipelineId}/sessions`, but is otherwise the same as + * [InferencePipelineService.retrieveSessions]. + */ + @MustBeClosed + fun retrieveSessions( + inferencePipelineId: String + ): HttpResponseFor = + retrieveSessions(inferencePipelineId, InferencePipelineRetrieveSessionsParams.none()) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveSessions( + params.toBuilder().inferencePipelineId(inferencePipelineId).build(), + requestOptions, + ) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + inferencePipelineId: String, + params: InferencePipelineRetrieveSessionsParams = + InferencePipelineRetrieveSessionsParams.none(), + ): HttpResponseFor = + retrieveSessions(inferencePipelineId, params, RequestOptions.none()) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams + ): HttpResponseFor = + retrieveSessions(params, RequestOptions.none()) + + /** @see retrieveSessions */ + @MustBeClosed + fun retrieveSessions( + inferencePipelineId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveSessions( + inferencePipelineId, + InferencePipelineRetrieveSessionsParams.none(), + requestOptions, + ) + + /** + * Returns a raw HTTP response for `post /inference-pipelines/{inferencePipelineId}/users`, * but is otherwise the same as [InferencePipelineService.retrieveUsers]. */ @MustBeClosed diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt index ddef7cad..e4a91c37 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt @@ -20,6 +20,8 @@ import com.openlayer.api.core.prepare import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersResponse import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams @@ -76,11 +78,18 @@ class InferencePipelineServiceImpl internal constructor(private val clientOption withRawResponse().delete(params, requestOptions) } + override fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + requestOptions: RequestOptions, + ): InferencePipelineRetrieveSessionsResponse = + // post /inference-pipelines/{inferencePipelineId}/sessions + withRawResponse().retrieveSessions(params, requestOptions).parse() + override fun retrieveUsers( params: InferencePipelineRetrieveUsersParams, requestOptions: RequestOptions, ): InferencePipelineRetrieveUsersResponse = - // get /inference-pipelines/{inferencePipelineId}/users + // post /inference-pipelines/{inferencePipelineId}/users withRawResponse().retrieveUsers(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -199,6 +208,37 @@ class InferencePipelineServiceImpl internal constructor(private val clientOption } } + private val retrieveSessionsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveSessions( + params: InferencePipelineRetrieveSessionsParams, + 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), "sessions") + .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 { retrieveSessionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val retrieveUsersHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -211,9 +251,10 @@ class InferencePipelineServiceImpl internal constructor(private val clientOption checkRequired("inferencePipelineId", params.inferencePipelineId().getOrNull()) val request = HttpRequest.builder() - .method(HttpMethod.GET) + .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) .addPathSegments("inference-pipelines", params._pathParam(0), "users") + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsParamsTest.kt new file mode 100644 index 00000000..b48df7c1 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsParamsTest.kt @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +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 InferencePipelineRetrieveSessionsParamsTest { + + @Test + fun create() { + InferencePipelineRetrieveSessionsParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveSessionsParams.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 = + InferencePipelineRetrieveSessionsParams.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 = + InferencePipelineRetrieveSessionsParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveSessionsParams.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 = + InferencePipelineRetrieveSessionsParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + InferencePipelineRetrieveSessionsParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveSessionsParams.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( + InferencePipelineRetrieveSessionsParams.ColumnFilter.ofSet( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveSessionsParams.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 = + InferencePipelineRetrieveSessionsParams.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/InferencePipelineRetrieveSessionsResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsResponseTest.kt new file mode 100644 index 00000000..763c7a7d --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveSessionsResponseTest.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.inferencepipelines + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InferencePipelineRetrieveSessionsResponseTest { + + @Test + fun create() { + val inferencePipelineRetrieveSessionsResponse = + InferencePipelineRetrieveSessionsResponse.builder() + .addItem( + InferencePipelineRetrieveSessionsResponse.Item.builder() + .id("session456") + .cost(0.025f) + .dateCreated(OffsetDateTime.parse("2022-01-02T08:00:00Z")) + .dateOfFirstRecord(OffsetDateTime.parse("2022-01-02T07:58:20Z")) + .dateOfLastRecord(OffsetDateTime.parse("2022-01-02T08:00:00Z")) + .duration(100576.341f) + .firstRecord( + InferencePipelineRetrieveSessionsResponse.Item.FirstRecord.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .lastRecord( + InferencePipelineRetrieveSessionsResponse.Item.LastRecord.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .latency(1250.5f) + .records(15L) + .tokens(1250.0f) + .addUserId("user123") + .addUserId("user456") + .build() + ) + .build() + + assertThat(inferencePipelineRetrieveSessionsResponse.items()) + .containsExactly( + InferencePipelineRetrieveSessionsResponse.Item.builder() + .id("session456") + .cost(0.025f) + .dateCreated(OffsetDateTime.parse("2022-01-02T08:00:00Z")) + .dateOfFirstRecord(OffsetDateTime.parse("2022-01-02T07:58:20Z")) + .dateOfLastRecord(OffsetDateTime.parse("2022-01-02T08:00:00Z")) + .duration(100576.341f) + .firstRecord( + InferencePipelineRetrieveSessionsResponse.Item.FirstRecord.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .lastRecord( + InferencePipelineRetrieveSessionsResponse.Item.LastRecord.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .latency(1250.5f) + .records(15L) + .tokens(1250.0f) + .addUserId("user123") + .addUserId("user456") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineRetrieveSessionsResponse = + InferencePipelineRetrieveSessionsResponse.builder() + .addItem( + InferencePipelineRetrieveSessionsResponse.Item.builder() + .id("session456") + .cost(0.025f) + .dateCreated(OffsetDateTime.parse("2022-01-02T08:00:00Z")) + .dateOfFirstRecord(OffsetDateTime.parse("2022-01-02T07:58:20Z")) + .dateOfLastRecord(OffsetDateTime.parse("2022-01-02T08:00:00Z")) + .duration(100576.341f) + .firstRecord( + InferencePipelineRetrieveSessionsResponse.Item.FirstRecord.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .lastRecord( + InferencePipelineRetrieveSessionsResponse.Item.LastRecord.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .latency(1250.5f) + .records(15L) + .tokens(1250.0f) + .addUserId("user123") + .addUserId("user456") + .build() + ) + .build() + + val roundtrippedInferencePipelineRetrieveSessionsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineRetrieveSessionsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineRetrieveSessionsResponse) + .isEqualTo(inferencePipelineRetrieveSessionsResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParamsTest.kt index e6514961..85c08e2e 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParamsTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveUsersParamsTest.kt @@ -3,6 +3,7 @@ package com.openlayer.api.models.inferencepipelines 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 @@ -12,8 +13,26 @@ internal class InferencePipelineRetrieveUsersParamsTest { fun create() { InferencePipelineRetrieveUsersParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) .page(1L) .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.Operator + .CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") .build() } @@ -34,14 +53,40 @@ internal class InferencePipelineRetrieveUsersParamsTest { val params = InferencePipelineRetrieveUsersParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) .page(1L) .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveUsersParams.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("page", "1").put("perPage", "1").build()) + .isEqualTo( + QueryParams.builder() + .put("asc", "true") + .put("page", "1") + .put("perPage", "1") + .put("sortColumn", "sortColumn") + .build() + ) } @Test @@ -55,4 +100,66 @@ internal class InferencePipelineRetrieveUsersParamsTest { assertThat(queryParams).isEqualTo(QueryParams.builder().build()) } + + @Test + fun body() { + val params = + InferencePipelineRetrieveUsersParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveUsersParams.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( + InferencePipelineRetrieveUsersParams.ColumnFilter.ofSet( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveUsersParams.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 = + InferencePipelineRetrieveUsersParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt index 43697a12..ef34c1a0 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncTest.kt @@ -5,6 +5,7 @@ package com.openlayer.api.services.async import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersParams import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams import org.junit.jupiter.api.Test @@ -71,6 +72,48 @@ internal class InferencePipelineServiceAsyncTest { val response = future.get() } + @Test + fun retrieveSessions() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineServiceAsync = client.inferencePipelines() + + val responseFuture = + inferencePipelineServiceAsync.retrieveSessions( + InferencePipelineRetrieveSessionsParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter + .builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter + .Operator + .CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun retrieveUsers() { val client = @@ -84,8 +127,27 @@ internal class InferencePipelineServiceAsyncTest { inferencePipelineServiceAsync.retrieveUsers( InferencePipelineRetrieveUsersParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) .page(1L) .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter + .Operator + .CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") .build() ) diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt index 8a3575cd..c5e457ee 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceTest.kt @@ -5,6 +5,7 @@ package com.openlayer.api.services.blocking import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams +import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveSessionsParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveUsersParams import com.openlayer.api.models.inferencepipelines.InferencePipelineUpdateParams import org.junit.jupiter.api.Test @@ -67,6 +68,47 @@ internal class InferencePipelineServiceTest { inferencePipelineService.delete("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } + @Test + fun retrieveSessions() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineService = client.inferencePipelines() + + val response = + inferencePipelineService.retrieveSessions( + InferencePipelineRetrieveSessionsParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) + .page(1L) + .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter + .builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveSessionsParams.ColumnFilter.SetColumnFilter + .Operator + .CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") + .build() + ) + + response.validate() + } + @Test fun retrieveUsers() { val client = @@ -80,8 +122,27 @@ internal class InferencePipelineServiceTest { inferencePipelineService.retrieveUsers( InferencePipelineRetrieveUsersParams.builder() .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .asc(true) .page(1L) .perPage(1L) + .sortColumn("sortColumn") + .addColumnFilter( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter.builder() + .measurement("openlayer_token_set") + .operator( + InferencePipelineRetrieveUsersParams.ColumnFilter.SetColumnFilter + .Operator + .CONTAINS_NONE + ) + .addValue("cat") + .build() + ) + .addExcludeRowIdList(0L) + .addNotSearchQueryAnd("string") + .addNotSearchQueryOr("string") + .addRowIdList(0L) + .addSearchQueryAnd("string") + .addSearchQueryOr("string") .build() )