From 03ce5d8b6df555ea91cddc3b2bd45fa734512d80 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Tue, 23 Jul 2024 00:38:10 +0000 Subject: [PATCH] feat(api): update via SDK Studio --- .stats.yml | 2 +- .../models/InferencePipelineUpdateParams.kt | 326 ++++++++++ .../models/InferencePipelineUpdateResponse.kt | 611 ++++++++++++++++++ .../async/InferencePipelineServiceAsync.kt | 9 + .../InferencePipelineServiceAsyncImpl.kt | 33 + .../blocking/InferencePipelineService.kt | 9 + .../blocking/InferencePipelineServiceImpl.kt | 32 + .../InferencePipelineUpdateParamsTest.kt | 59 ++ .../InferencePipelineUpdateResponseTest.kt | 71 ++ .../blocking/InferencePipelineServiceTest.kt | 21 + 10 files changed, 1172 insertions(+), 1 deletion(-) create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 6ecfe8d..6a8c142 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 12 +configured_endpoints: 13 diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt new file mode 100644 index 0000000..66bece6 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateParams.kt @@ -0,0 +1,326 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.toUnmodifiable +import com.openlayer.api.models.* +import java.util.Objects +import java.util.Optional + +class InferencePipelineUpdateParams +constructor( + private val inferencePipelineId: String, + private val description: String?, + private val name: String?, + private val referenceDatasetUri: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun inferencePipelineId(): String = inferencePipelineId + + fun description(): Optional = Optional.ofNullable(description) + + fun name(): Optional = Optional.ofNullable(name) + + fun referenceDatasetUri(): Optional = Optional.ofNullable(referenceDatasetUri) + + @JvmSynthetic + internal fun getBody(): InferencePipelineUpdateBody { + return InferencePipelineUpdateBody( + description, + name, + referenceDatasetUri, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> inferencePipelineId + else -> "" + } + } + + @JsonDeserialize(builder = InferencePipelineUpdateBody.Builder::class) + @NoAutoDetect + class InferencePipelineUpdateBody + internal constructor( + private val description: String?, + private val name: String?, + private val referenceDatasetUri: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** The inference pipeline description. */ + @JsonProperty("description") fun description(): String? = description + + /** The inference pipeline name. */ + @JsonProperty("name") fun name(): String? = name + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to + * handle your reference dataset updates. + */ + @JsonProperty("referenceDatasetUri") + fun referenceDatasetUri(): String? = referenceDatasetUri + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineUpdateBody && + this.description == other.description && + this.name == other.name && + this.referenceDatasetUri == other.referenceDatasetUri && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + description, + name, + referenceDatasetUri, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InferencePipelineUpdateBody{description=$description, name=$name, referenceDatasetUri=$referenceDatasetUri, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var description: String? = null + private var name: String? = null + private var referenceDatasetUri: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineUpdateBody: InferencePipelineUpdateBody) = apply { + this.description = inferencePipelineUpdateBody.description + this.name = inferencePipelineUpdateBody.name + this.referenceDatasetUri = inferencePipelineUpdateBody.referenceDatasetUri + additionalProperties(inferencePipelineUpdateBody.additionalProperties) + } + + /** The inference pipeline description. */ + @JsonProperty("description") + fun description(description: String) = apply { this.description = description } + + /** The inference pipeline name. */ + @JsonProperty("name") fun name(name: String) = apply { this.name = name } + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the + * UI to handle your reference dataset updates. + */ + @JsonProperty("referenceDatasetUri") + fun referenceDatasetUri(referenceDatasetUri: String) = apply { + this.referenceDatasetUri = referenceDatasetUri + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InferencePipelineUpdateBody = + InferencePipelineUpdateBody( + description, + name, + referenceDatasetUri, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineUpdateParams && + this.inferencePipelineId == other.inferencePipelineId && + this.description == other.description && + this.name == other.name && + this.referenceDatasetUri == other.referenceDatasetUri && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + inferencePipelineId, + description, + name, + referenceDatasetUri, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "InferencePipelineUpdateParams{inferencePipelineId=$inferencePipelineId, description=$description, name=$name, referenceDatasetUri=$referenceDatasetUri, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var inferencePipelineId: String? = null + private var description: String? = null + private var name: String? = null + private var referenceDatasetUri: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineUpdateParams: InferencePipelineUpdateParams) = apply { + this.inferencePipelineId = inferencePipelineUpdateParams.inferencePipelineId + this.description = inferencePipelineUpdateParams.description + this.name = inferencePipelineUpdateParams.name + this.referenceDatasetUri = inferencePipelineUpdateParams.referenceDatasetUri + additionalQueryParams(inferencePipelineUpdateParams.additionalQueryParams) + additionalHeaders(inferencePipelineUpdateParams.additionalHeaders) + additionalBodyProperties(inferencePipelineUpdateParams.additionalBodyProperties) + } + + fun inferencePipelineId(inferencePipelineId: String) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** The inference pipeline description. */ + fun description(description: String) = apply { this.description = description } + + /** The inference pipeline name. */ + fun name(name: String) = apply { this.name = name } + + /** + * The storage uri of your reference dataset. We recommend using the Python SDK or the UI to + * handle your reference dataset updates. + */ + fun referenceDatasetUri(referenceDatasetUri: String) = apply { + this.referenceDatasetUri = referenceDatasetUri + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): InferencePipelineUpdateParams = + InferencePipelineUpdateParams( + checkNotNull(inferencePipelineId) { + "`inferencePipelineId` is required but was not set" + }, + description, + name, + referenceDatasetUri, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt new file mode 100644 index 0000000..3e7d741 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponse.kt @@ -0,0 +1,611 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.toUnmodifiable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = InferencePipelineUpdateResponse.Builder::class) +@NoAutoDetect +class InferencePipelineUpdateResponse +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val name: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val dateLastSampleReceived: JsonField, + private val description: JsonField, + private val dateLastEvaluated: JsonField, + private val dateOfNextEvaluation: JsonField, + private val passingGoalCount: JsonField, + private val failingGoalCount: JsonField, + private val totalGoalCount: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val links: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + /** The inference pipeline id. */ + fun id(): String = id.getRequired("id") + + /** The project id. */ + fun projectId(): String = projectId.getRequired("projectId") + + /** The inference pipeline name. */ + fun name(): String = name.getRequired("name") + + /** The creation date. */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** The last updated date. */ + fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** The last data sample received date. */ + fun dateLastSampleReceived(): Optional = + Optional.ofNullable(dateLastSampleReceived.getNullable("dateLastSampleReceived")) + + /** The inference pipeline description. */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The last test evaluation date. */ + fun dateLastEvaluated(): Optional = + Optional.ofNullable(dateLastEvaluated.getNullable("dateLastEvaluated")) + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(): Optional = + Optional.ofNullable(dateOfNextEvaluation.getNullable("dateOfNextEvaluation")) + + /** The number of tests passing. */ + fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** The number of tests failing. */ + fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** The total number of tests. */ + fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + /** The status of test evaluation for the inference pipeline. */ + fun status(): Status = status.getRequired("status") + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(): Optional = + Optional.ofNullable(statusMessage.getNullable("statusMessage")) + + fun links(): Links = links.getRequired("links") + + /** The inference pipeline id. */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The project id. */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId + + /** The inference pipeline name. */ + @JsonProperty("name") @ExcludeMissing fun _name() = name + + /** The creation date. */ + @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated + + /** The last updated date. */ + @JsonProperty("dateUpdated") @ExcludeMissing fun _dateUpdated() = dateUpdated + + /** The last data sample received date. */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun _dateLastSampleReceived() = dateLastSampleReceived + + /** The inference pipeline description. */ + @JsonProperty("description") @ExcludeMissing fun _description() = description + + /** The last test evaluation date. */ + @JsonProperty("dateLastEvaluated") @ExcludeMissing fun _dateLastEvaluated() = dateLastEvaluated + + /** The next test evaluation date. */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun _dateOfNextEvaluation() = dateOfNextEvaluation + + /** The number of tests passing. */ + @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount + + /** The number of tests failing. */ + @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount + + /** The total number of tests. */ + @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount + + /** The status of test evaluation for the inference pipeline. */ + @JsonProperty("status") @ExcludeMissing fun _status() = status + + /** The status message of test evaluation for the inference pipeline. */ + @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage + + @JsonProperty("links") @ExcludeMissing fun _links() = links + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InferencePipelineUpdateResponse = apply { + if (!validated) { + id() + projectId() + name() + dateCreated() + dateUpdated() + dateLastSampleReceived() + description() + dateLastEvaluated() + dateOfNextEvaluation() + passingGoalCount() + failingGoalCount() + totalGoalCount() + status() + statusMessage() + links().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineUpdateResponse && + this.id == other.id && + this.projectId == other.projectId && + this.name == other.name && + this.dateCreated == other.dateCreated && + this.dateUpdated == other.dateUpdated && + this.dateLastSampleReceived == other.dateLastSampleReceived && + this.description == other.description && + this.dateLastEvaluated == other.dateLastEvaluated && + this.dateOfNextEvaluation == other.dateOfNextEvaluation && + this.passingGoalCount == other.passingGoalCount && + this.failingGoalCount == other.failingGoalCount && + this.totalGoalCount == other.totalGoalCount && + this.status == other.status && + this.statusMessage == other.statusMessage && + this.links == other.links && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + id, + projectId, + name, + dateCreated, + dateUpdated, + dateLastSampleReceived, + description, + dateLastEvaluated, + dateOfNextEvaluation, + passingGoalCount, + failingGoalCount, + totalGoalCount, + status, + statusMessage, + links, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InferencePipelineUpdateResponse{id=$id, projectId=$projectId, name=$name, dateCreated=$dateCreated, dateUpdated=$dateUpdated, dateLastSampleReceived=$dateLastSampleReceived, description=$description, dateLastEvaluated=$dateLastEvaluated, dateOfNextEvaluation=$dateOfNextEvaluation, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, status=$status, statusMessage=$statusMessage, links=$links, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var dateCreated: JsonField = JsonMissing.of() + private var dateUpdated: JsonField = JsonMissing.of() + private var dateLastSampleReceived: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var dateLastEvaluated: JsonField = JsonMissing.of() + private var dateOfNextEvaluation: JsonField = JsonMissing.of() + private var passingGoalCount: JsonField = JsonMissing.of() + private var failingGoalCount: JsonField = JsonMissing.of() + private var totalGoalCount: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var statusMessage: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineUpdateResponse: InferencePipelineUpdateResponse) = + apply { + this.id = inferencePipelineUpdateResponse.id + this.projectId = inferencePipelineUpdateResponse.projectId + this.name = inferencePipelineUpdateResponse.name + this.dateCreated = inferencePipelineUpdateResponse.dateCreated + this.dateUpdated = inferencePipelineUpdateResponse.dateUpdated + this.dateLastSampleReceived = inferencePipelineUpdateResponse.dateLastSampleReceived + this.description = inferencePipelineUpdateResponse.description + this.dateLastEvaluated = inferencePipelineUpdateResponse.dateLastEvaluated + this.dateOfNextEvaluation = inferencePipelineUpdateResponse.dateOfNextEvaluation + this.passingGoalCount = inferencePipelineUpdateResponse.passingGoalCount + this.failingGoalCount = inferencePipelineUpdateResponse.failingGoalCount + this.totalGoalCount = inferencePipelineUpdateResponse.totalGoalCount + this.status = inferencePipelineUpdateResponse.status + this.statusMessage = inferencePipelineUpdateResponse.statusMessage + this.links = inferencePipelineUpdateResponse.links + additionalProperties(inferencePipelineUpdateResponse.additionalProperties) + } + + /** The inference pipeline id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** The inference pipeline id. */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** The project id. */ + @JsonProperty("projectId") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The inference pipeline name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The inference pipeline name. */ + @JsonProperty("name") + @ExcludeMissing + fun name(name: JsonField) = apply { this.name = name } + + /** The creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** The creation date. */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** The last updated date. */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The last data sample received date. */ + fun dateLastSampleReceived(dateLastSampleReceived: OffsetDateTime) = + dateLastSampleReceived(JsonField.of(dateLastSampleReceived)) + + /** The last data sample received date. */ + @JsonProperty("dateLastSampleReceived") + @ExcludeMissing + fun dateLastSampleReceived(dateLastSampleReceived: JsonField) = apply { + this.dateLastSampleReceived = dateLastSampleReceived + } + + /** The inference pipeline description. */ + fun description(description: String) = description(JsonField.of(description)) + + /** The inference pipeline description. */ + @JsonProperty("description") + @ExcludeMissing + fun description(description: JsonField) = apply { this.description = description } + + /** The last test evaluation date. */ + fun dateLastEvaluated(dateLastEvaluated: OffsetDateTime) = + dateLastEvaluated(JsonField.of(dateLastEvaluated)) + + /** The last test evaluation date. */ + @JsonProperty("dateLastEvaluated") + @ExcludeMissing + fun dateLastEvaluated(dateLastEvaluated: JsonField) = apply { + this.dateLastEvaluated = dateLastEvaluated + } + + /** The next test evaluation date. */ + fun dateOfNextEvaluation(dateOfNextEvaluation: OffsetDateTime) = + dateOfNextEvaluation(JsonField.of(dateOfNextEvaluation)) + + /** The next test evaluation date. */ + @JsonProperty("dateOfNextEvaluation") + @ExcludeMissing + fun dateOfNextEvaluation(dateOfNextEvaluation: JsonField) = apply { + this.dateOfNextEvaluation = dateOfNextEvaluation + } + + /** The number of tests passing. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** The number of tests passing. */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The number of tests failing. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** The number of tests failing. */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + /** The total number of tests. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** The total number of tests. */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + /** The status of test evaluation for the inference pipeline. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** The status of test evaluation for the inference pipeline. */ + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + /** The status message of test evaluation for the inference pipeline. */ + fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) + + /** The status message of test evaluation for the inference pipeline. */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + fun links(links: Links) = links(JsonField.of(links)) + + @JsonProperty("links") + @ExcludeMissing + fun links(links: JsonField) = apply { this.links = links } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InferencePipelineUpdateResponse = + InferencePipelineUpdateResponse( + id, + projectId, + name, + dateCreated, + dateUpdated, + dateLastSampleReceived, + description, + dateLastEvaluated, + dateOfNextEvaluation, + passingGoalCount, + failingGoalCount, + totalGoalCount, + status, + statusMessage, + links, + additionalProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Links.Builder::class) + @NoAutoDetect + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun app(): String = app.getRequired("app") + + @JsonProperty("app") @ExcludeMissing fun _app() = app + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Links = apply { + if (!validated) { + app() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Links && + this.app == other.app && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(app, additionalProperties) + } + return hashCode + } + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var app: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + this.app = links.app + additionalProperties(links.additionalProperties) + } + + fun app(app: String) = app(JsonField.of(app)) + + @JsonProperty("app") + @ExcludeMissing + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Links = Links(app, additionalProperties.toUnmodifiable()) + } + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val QUEUED = Status(JsonField.of("queued")) + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PAUSED = Status(JsonField.of("paused")) + + @JvmField val FAILED = Status(JsonField.of("failed")) + + @JvmField val COMPLETED = Status(JsonField.of("completed")) + + @JvmField val UNKNOWN = Status(JsonField.of("unknown")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + enum class Value { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} 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 59d093a..84e6d9a 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 @@ -8,6 +8,8 @@ import com.openlayer.api.core.RequestOptions import com.openlayer.api.models.InferencePipelineDeleteParams import com.openlayer.api.models.InferencePipelineRetrieveParams import com.openlayer.api.models.InferencePipelineRetrieveResponse +import com.openlayer.api.models.InferencePipelineUpdateParams +import com.openlayer.api.models.InferencePipelineUpdateResponse import com.openlayer.api.services.async.inferencePipelines.DataServiceAsync import com.openlayer.api.services.async.inferencePipelines.RowServiceAsync import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsync @@ -28,6 +30,13 @@ interface InferencePipelineServiceAsync { requestOptions: RequestOptions = RequestOptions.none() ): CompletableFuture + /** Update inference pipeline. */ + @JvmOverloads + fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + /** Delete inference pipeline. */ @JvmOverloads fun delete( 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 04568a9..c5fd091 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 @@ -11,6 +11,8 @@ import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.InferencePipelineDeleteParams import com.openlayer.api.models.InferencePipelineRetrieveParams import com.openlayer.api.models.InferencePipelineRetrieveResponse +import com.openlayer.api.models.InferencePipelineUpdateParams +import com.openlayer.api.models.InferencePipelineUpdateResponse import com.openlayer.api.services.async.inferencePipelines.DataServiceAsync import com.openlayer.api.services.async.inferencePipelines.DataServiceAsyncImpl import com.openlayer.api.services.async.inferencePipelines.RowServiceAsync @@ -75,6 +77,37 @@ constructor( } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Update inference pipeline. */ + override fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Delete inference pipeline. */ 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 259e545..8b22b53 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 @@ -8,6 +8,8 @@ import com.openlayer.api.core.RequestOptions import com.openlayer.api.models.InferencePipelineDeleteParams import com.openlayer.api.models.InferencePipelineRetrieveParams import com.openlayer.api.models.InferencePipelineRetrieveResponse +import com.openlayer.api.models.InferencePipelineUpdateParams +import com.openlayer.api.models.InferencePipelineUpdateResponse import com.openlayer.api.services.blocking.inferencePipelines.DataService import com.openlayer.api.services.blocking.inferencePipelines.RowService import com.openlayer.api.services.blocking.inferencePipelines.TestResultService @@ -27,6 +29,13 @@ interface InferencePipelineService { requestOptions: RequestOptions = RequestOptions.none() ): InferencePipelineRetrieveResponse + /** Update inference pipeline. */ + @JvmOverloads + fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): InferencePipelineUpdateResponse + /** Delete inference pipeline. */ @JvmOverloads fun delete( 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 2771de7..efc4fb6 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 @@ -11,6 +11,8 @@ import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.InferencePipelineDeleteParams import com.openlayer.api.models.InferencePipelineRetrieveParams import com.openlayer.api.models.InferencePipelineRetrieveResponse +import com.openlayer.api.models.InferencePipelineUpdateParams +import com.openlayer.api.models.InferencePipelineUpdateResponse import com.openlayer.api.services.blocking.inferencePipelines.DataService import com.openlayer.api.services.blocking.inferencePipelines.DataServiceImpl import com.openlayer.api.services.blocking.inferencePipelines.RowService @@ -71,6 +73,36 @@ constructor( } } + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Update inference pipeline. */ + override fun update( + params: InferencePipelineUpdateParams, + requestOptions: RequestOptions + ): InferencePipelineUpdateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params.getPathParam(0)) + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { updateHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + private val deleteHandler: Handler = emptyHandler().withErrorHandler(errorHandler) /** Delete inference pipeline. */ diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt new file mode 100644 index 0000000..ffecf85 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateParamsTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.openlayer.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InferencePipelineUpdateParamsTest { + + @Test + fun createInferencePipelineUpdateParams() { + InferencePipelineUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("This pipeline is used for production.") + .name("production") + .referenceDatasetUri("referenceDatasetUri") + .build() + } + + @Test + fun getBody() { + val params = + InferencePipelineUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("This pipeline is used for production.") + .name("production") + .referenceDatasetUri("referenceDatasetUri") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.description()).isEqualTo("This pipeline is used for production.") + assertThat(body.name()).isEqualTo("production") + assertThat(body.referenceDatasetUri()).isEqualTo("referenceDatasetUri") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + InferencePipelineUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + InferencePipelineUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "inferencePipelineId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt new file mode 100644 index 0000000..35af791 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineUpdateResponseTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InferencePipelineUpdateResponseTest { + + @Test + fun createInferencePipelineUpdateResponse() { + val inferencePipelineUpdateResponse = + InferencePipelineUpdateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(123L) + .links( + InferencePipelineUpdateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(123L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineUpdateResponse.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(123L) + .build() + assertThat(inferencePipelineUpdateResponse).isNotNull + assertThat(inferencePipelineUpdateResponse.id()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(inferencePipelineUpdateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineUpdateResponse.dateLastEvaluated()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineUpdateResponse.dateLastSampleReceived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineUpdateResponse.dateOfNextEvaluation()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineUpdateResponse.dateUpdated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(inferencePipelineUpdateResponse.description()) + .contains("This pipeline is used for production.") + assertThat(inferencePipelineUpdateResponse.failingGoalCount()).isEqualTo(123L) + assertThat(inferencePipelineUpdateResponse.links()) + .isEqualTo( + InferencePipelineUpdateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + assertThat(inferencePipelineUpdateResponse.name()).isEqualTo("production") + assertThat(inferencePipelineUpdateResponse.passingGoalCount()).isEqualTo(123L) + assertThat(inferencePipelineUpdateResponse.projectId()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(inferencePipelineUpdateResponse.status()) + .isEqualTo(InferencePipelineUpdateResponse.Status.QUEUED) + assertThat(inferencePipelineUpdateResponse.statusMessage()) + .contains("Tests successfully evaluated") + assertThat(inferencePipelineUpdateResponse.totalGoalCount()).isEqualTo(123L) + } +} 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 679b32c..d4ca7e1 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 @@ -29,6 +29,27 @@ class InferencePipelineServiceTest { inferencePipelineRetrieveResponse.validate() } + @Test + fun callUpdate() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inferencePipelineService = client.inferencePipelines() + val inferencePipelineUpdateResponse = + inferencePipelineService.update( + InferencePipelineUpdateParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .description("This pipeline is used for production.") + .name("production") + .referenceDatasetUri("referenceDatasetUri") + .build() + ) + println(inferencePipelineUpdateResponse) + inferencePipelineUpdateResponse.validate() + } + @Test fun callDelete() { val client =