diff --git a/.stats.yml b/.stats.yml index 9f97df3f..5a026d5a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 149 +configured_endpoints: 156 diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateParams.kt new file mode 100644 index 00000000..92042151 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateParams.kt @@ -0,0 +1,997 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkKnown +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Add RUN or THREAD items to a single annotation queue. THREAD items require thread_id and + * session_id; RUN items require run_id, or source_proposed_example_id with lookup coordinates when + * applicable. + */ +class ItemCreateParams +private constructor( + private val queueId: String?, + private val extendTraceRetention: Boolean?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** Extend trace retention for added run items */ + fun extendTraceRetention(): Optional = Optional.ofNullable(extendTraceRetention) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = body.items() + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _items(): JsonField> = body._items() + + 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(): ItemCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ItemCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemCreateParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var extendTraceRetention: Boolean? = 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(itemCreateParams: ItemCreateParams) = apply { + queueId = itemCreateParams.queueId + extendTraceRetention = itemCreateParams.extendTraceRetention + body = itemCreateParams.body.toBuilder() + additionalHeaders = itemCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = itemCreateParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + /** Extend trace retention for added run items */ + fun extendTraceRetention(extendTraceRetention: Boolean?) = apply { + this.extendTraceRetention = extendTraceRetention + } + + /** + * Alias for [Builder.extendTraceRetention]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun extendTraceRetention(extendTraceRetention: Boolean) = + extendTraceRetention(extendTraceRetention as Boolean?) + + /** + * Alias for calling [Builder.extendTraceRetention] with + * `extendTraceRetention.orElse(null)`. + */ + fun extendTraceRetention(extendTraceRetention: Optional) = + extendTraceRetention(extendTraceRetention.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: + * - [items] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun items(items: List) = apply { body.items(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 { body.items(items) } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { body.addItem(item) } + + 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 [ItemCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemCreateParams = + ItemCreateParams( + queueId, + extendTraceRetention, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + extendTraceRetention?.let { put("extend_trace_retention", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("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 [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + items = body.items.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { + checkKnown("items", it).add(item) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (items ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + items().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{items=$items, additionalProperties=$additionalProperties}" + } + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val itemType: JsonField, + private val runId: JsonField, + private val sessionId: JsonField, + private val sourceProposedExampleId: JsonField, + private val startTime: JsonField, + private val threadId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("item_type") + @ExcludeMissing + itemType: JsonField = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField = JsonMissing.of(), + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + sourceProposedExampleId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("thread_id") + @ExcludeMissing + threadId: JsonField = JsonMissing.of(), + ) : this( + itemType, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun itemType(): Optional = itemType.getOptional("item_type") + + /** + * RUN fields + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional = runId.getOptional("run_id") + + /** + * Shared optional SmithDB lookup coords. StartTime uses FlexTime because smith-backend and + * ClickHouse emit naive UTC timestamps (no timezone suffix) that strict *time.Time JSON + * unmarshaling rejects. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * SourceProposedExampleID is usually unset. When Issues Board / Engine suggested examples + * are added to a queue, the UI sets this to the tracer_session_issue_proposed_examples row + * so the queue item can point back at that suggestion. + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceProposedExampleId(): Optional = + sourceProposedExampleId.getOptional("source_proposed_example_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * THREAD fields (thread_id + session_id required) + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threadId(): Optional = threadId.getOptional("thread_id") + + /** + * Returns the raw JSON value of [itemType]. + * + * Unlike [itemType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_type") @ExcludeMissing fun _itemType(): JsonField = itemType + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField = runId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [sourceProposedExampleId]. + * + * Unlike [sourceProposedExampleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + fun _sourceProposedExampleId(): JsonField = sourceProposedExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId + + @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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var itemType: JsonField = JsonMissing.of() + private var runId: JsonField = JsonMissing.of() + private var sessionId: JsonField = JsonMissing.of() + private var sourceProposedExampleId: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var threadId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + itemType = item.itemType + runId = item.runId + sessionId = item.sessionId + sourceProposedExampleId = item.sourceProposedExampleId + startTime = item.startTime + threadId = item.threadId + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun itemType(itemType: ItemType) = itemType(JsonField.of(itemType)) + + /** + * Sets [Builder.itemType] to an arbitrary JSON value. + * + * You should usually call [Builder.itemType] with a well-typed [ItemType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun itemType(itemType: JsonField) = apply { this.itemType = itemType } + + /** RUN fields */ + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + /** + * Shared optional SmithDB lookup coords. StartTime uses FlexTime because smith-backend + * and ClickHouse emit naive UTC timestamps (no timezone suffix) that strict *time.Time + * JSON unmarshaling rejects. + */ + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + /** + * SourceProposedExampleID is usually unset. When Issues Board / Engine suggested + * examples are added to a queue, the UI sets this to the + * tracer_session_issue_proposed_examples row so the queue item can point back at that + * suggestion. + */ + fun sourceProposedExampleId(sourceProposedExampleId: String) = + sourceProposedExampleId(JsonField.of(sourceProposedExampleId)) + + /** + * Sets [Builder.sourceProposedExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceProposedExampleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceProposedExampleId(sourceProposedExampleId: JsonField) = apply { + this.sourceProposedExampleId = sourceProposedExampleId + } + + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + /** THREAD fields (thread_id + session_id required) */ + fun threadId(threadId: String) = threadId(JsonField.of(threadId)) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun threadId(threadId: JsonField) = apply { this.threadId = threadId } + + 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. + */ + fun build(): Item = + Item( + itemType, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Item = apply { + if (validated) { + return@apply + } + + itemType().ifPresent { it.validate() } + runId() + sessionId() + sourceProposedExampleId() + startTime() + threadId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 = + (itemType.asKnown().getOrNull()?.validity() ?: 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sourceProposedExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + class ItemType @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 RUN = of("RUN") + + @JvmField val THREAD = of("THREAD") + + @JvmStatic fun of(value: String) = ItemType(JsonField.of(value)) + } + + /** An enum containing [ItemType]'s known values. */ + enum class Known { + RUN, + THREAD, + } + + /** + * An enum containing [ItemType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ItemType] 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 { + RUN, + THREAD, + /** + * An enum member indicating that [ItemType] 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) { + RUN -> Value.RUN + THREAD -> Value.THREAD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + THREAD -> Known.THREAD + else -> throw LangChainInvalidDataException("Unknown ItemType: $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 LangChainInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ItemType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemType && 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 Item && + itemType == other.itemType && + runId == other.runId && + sessionId == other.sessionId && + sourceProposedExampleId == other.sourceProposedExampleId && + startTime == other.startTime && + threadId == other.threadId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + itemType, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{itemType=$itemType, runId=$runId, sessionId=$sessionId, sourceProposedExampleId=$sourceProposedExampleId, startTime=$startTime, threadId=$threadId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemCreateParams && + queueId == other.queueId && + extendTraceRetention == other.extendTraceRetention && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, extendTraceRetention, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ItemCreateParams{queueId=$queueId, extendTraceRetention=$extendTraceRetention, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateResponse.kt new file mode 100644 index 00000000..f6d1056f --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateResponse.kt @@ -0,0 +1,819 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.checkKnown +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ItemCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("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 [ItemCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemCreateResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemCreateResponse: ItemCreateResponse) = apply { + items = itemCreateResponse.items.map { it.toMutableList() } + additionalProperties = itemCreateResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ItemCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemCreateResponse = + ItemCreateResponse( + (items ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemCreateResponse = apply { + if (validated) { + return@apply + } + + items().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 addedAt: JsonField, + private val itemType: JsonField, + private val lastReviewedTime: JsonField, + private val queueId: JsonField, + private val runId: JsonField, + private val sessionId: JsonField, + private val sourceProposedExampleId: JsonField, + private val startTime: JsonField, + private val threadId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("added_at") @ExcludeMissing addedAt: JsonField = JsonMissing.of(), + @JsonProperty("item_type") + @ExcludeMissing + itemType: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + @JsonProperty("queue_id") @ExcludeMissing queueId: JsonField = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), + @JsonProperty("session_id") + @ExcludeMissing + sessionId: JsonField = JsonMissing.of(), + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + sourceProposedExampleId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("thread_id") + @ExcludeMissing + threadId: JsonField = JsonMissing.of(), + ) : this( + id, + addedAt, + itemType, + lastReviewedTime, + queueId, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun itemType(): Optional = itemType.getOptional("item_type") + + /** + * LastReviewedTime is always present on the wire (null until reviewed). + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = + lastReviewedTime.getOptional("last_reviewed_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun queueId(): Optional = queueId.getOptional("queue_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun runId(): Optional = runId.getOptional("run_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sourceProposedExampleId(): Optional = + sourceProposedExampleId.getOptional("source_proposed_example_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun threadId(): Optional = threadId.getOptional("thread_id") + + /** + * 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 [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [itemType]. + * + * Unlike [itemType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_type") @ExcludeMissing fun _itemType(): JsonField = itemType + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + /** + * Returns the raw JSON value of [queueId]. + * + * Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_id") @ExcludeMissing fun _queueId(): JsonField = queueId + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField = runId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [sourceProposedExampleId]. + * + * Unlike [sourceProposedExampleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + fun _sourceProposedExampleId(): JsonField = sourceProposedExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") @ExcludeMissing fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId + + @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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var addedAt: JsonField = JsonMissing.of() + private var itemType: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var queueId: JsonField = JsonMissing.of() + private var runId: JsonField = JsonMissing.of() + private var sessionId: JsonField = JsonMissing.of() + private var sourceProposedExampleId: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var threadId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + addedAt = item.addedAt + itemType = item.itemType + lastReviewedTime = item.lastReviewedTime + queueId = item.queueId + runId = item.runId + sessionId = item.sessionId + sourceProposedExampleId = item.sourceProposedExampleId + startTime = item.startTime + threadId = item.threadId + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun addedAt(addedAt: String) = addedAt(JsonField.of(addedAt)) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun itemType(itemType: ItemType) = itemType(JsonField.of(itemType)) + + /** + * Sets [Builder.itemType] to an arbitrary JSON value. + * + * You should usually call [Builder.itemType] with a well-typed [ItemType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun itemType(itemType: JsonField) = apply { this.itemType = itemType } + + /** LastReviewedTime is always present on the wire (null until reviewed). */ + fun lastReviewedTime(lastReviewedTime: String) = + lastReviewedTime(JsonField.of(lastReviewedTime)) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + fun queueId(queueId: String) = queueId(JsonField.of(queueId)) + + /** + * Sets [Builder.queueId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun queueId(queueId: JsonField) = apply { this.queueId = queueId } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun sourceProposedExampleId(sourceProposedExampleId: String) = + sourceProposedExampleId(JsonField.of(sourceProposedExampleId)) + + /** + * Sets [Builder.sourceProposedExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceProposedExampleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceProposedExampleId(sourceProposedExampleId: JsonField) = apply { + this.sourceProposedExampleId = sourceProposedExampleId + } + + fun startTime(startTime: String) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { this.startTime = startTime } + + fun threadId(threadId: String) = threadId(JsonField.of(threadId)) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun threadId(threadId: JsonField) = apply { this.threadId = threadId } + + 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. + */ + fun build(): Item = + Item( + id, + addedAt, + itemType, + lastReviewedTime, + queueId, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + addedAt() + itemType().ifPresent { it.validate() } + lastReviewedTime() + queueId() + runId() + sessionId() + sourceProposedExampleId() + startTime() + threadId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (addedAt.asKnown().isPresent) 1 else 0) + + (itemType.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + (if (queueId.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sourceProposedExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + class ItemType @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 RUN = of("RUN") + + @JvmField val THREAD = of("THREAD") + + @JvmStatic fun of(value: String) = ItemType(JsonField.of(value)) + } + + /** An enum containing [ItemType]'s known values. */ + enum class Known { + RUN, + THREAD, + } + + /** + * An enum containing [ItemType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ItemType] 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 { + RUN, + THREAD, + /** + * An enum member indicating that [ItemType] 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) { + RUN -> Value.RUN + THREAD -> Value.THREAD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + THREAD -> Known.THREAD + else -> throw LangChainInvalidDataException("Unknown ItemType: $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 LangChainInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ItemType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemType && 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 Item && + id == other.id && + addedAt == other.addedAt && + itemType == other.itemType && + lastReviewedTime == other.lastReviewedTime && + queueId == other.queueId && + runId == other.runId && + sessionId == other.sessionId && + sourceProposedExampleId == other.sourceProposedExampleId && + startTime == other.startTime && + threadId == other.threadId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + addedAt, + itemType, + lastReviewedTime, + queueId, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, addedAt=$addedAt, itemType=$itemType, lastReviewedTime=$lastReviewedTime, queueId=$queueId, runId=$runId, sessionId=$sessionId, sourceProposedExampleId=$sourceProposedExampleId, startTime=$startTime, threadId=$threadId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemCreateResponse && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemCreateResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusParams.kt new file mode 100644 index 00000000..a5096125 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusParams.kt @@ -0,0 +1,623 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.Params +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Log the caller's reviewer status for a RUN or THREAD annotation queue item. A null status + * re-shows the item for this reviewer. + */ +class ItemCreateStatusParams +private constructor( + private val queueItemId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueItemId(): Optional = Optional.ofNullable(queueItemId) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overrideAddedAt(): Optional = body.overrideAddedAt() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = body.status() + + /** + * Returns the raw JSON value of [overrideAddedAt]. + * + * Unlike [overrideAddedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _overrideAddedAt(): JsonField = body._overrideAddedAt() + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _status(): JsonField = body._status() + + 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(): ItemCreateStatusParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ItemCreateStatusParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemCreateStatusParams]. */ + class Builder internal constructor() { + + private var queueItemId: 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(itemCreateStatusParams: ItemCreateStatusParams) = apply { + queueItemId = itemCreateStatusParams.queueItemId + body = itemCreateStatusParams.body.toBuilder() + additionalHeaders = itemCreateStatusParams.additionalHeaders.toBuilder() + additionalQueryParams = itemCreateStatusParams.additionalQueryParams.toBuilder() + } + + fun queueItemId(queueItemId: String?) = apply { this.queueItemId = queueItemId } + + /** Alias for calling [Builder.queueItemId] with `queueItemId.orElse(null)`. */ + fun queueItemId(queueItemId: Optional) = queueItemId(queueItemId.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: + * - [overrideAddedAt] + * - [status] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun overrideAddedAt(overrideAddedAt: String) = apply { + body.overrideAddedAt(overrideAddedAt) + } + + /** + * Sets [Builder.overrideAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.overrideAddedAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overrideAddedAt(overrideAddedAt: JsonField) = apply { + body.overrideAddedAt(overrideAddedAt) + } + + fun status(status: Status) = apply { body.status(status) } + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { body.status(status) } + + 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 [ItemCreateStatusParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemCreateStatusParams = + ItemCreateStatusParams( + queueItemId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueItemId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val overrideAddedAt: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("override_added_at") + @ExcludeMissing + overrideAddedAt: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(overrideAddedAt, status, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun overrideAddedAt(): Optional = overrideAddedAt.getOptional("override_added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [overrideAddedAt]. + * + * Unlike [overrideAddedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("override_added_at") + @ExcludeMissing + fun _overrideAddedAt(): JsonField = overrideAddedAt + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @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 overrideAddedAt: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + overrideAddedAt = body.overrideAddedAt + status = body.status + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun overrideAddedAt(overrideAddedAt: String) = + overrideAddedAt(JsonField.of(overrideAddedAt)) + + /** + * Sets [Builder.overrideAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.overrideAddedAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overrideAddedAt(overrideAddedAt: JsonField) = apply { + this.overrideAddedAt = overrideAddedAt + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + 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(overrideAddedAt, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + overrideAddedAt() + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (overrideAddedAt.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + overrideAddedAt == other.overrideAddedAt && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(overrideAddedAt, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{overrideAddedAt=$overrideAddedAt, status=$status, additionalProperties=$additionalProperties}" + } + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VIEWED = of("viewed") + + @JvmField val COMPLETED = of("completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + VIEWED, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VIEWED, + COMPLETED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VIEWED -> Value.VIEWED + COMPLETED -> Value.COMPLETED + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VIEWED -> Known.VIEWED + COMPLETED -> Known.COMPLETED + else -> throw LangChainInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 Status && 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 ItemCreateStatusParams && + queueItemId == other.queueItemId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueItemId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ItemCreateStatusParams{queueItemId=$queueItemId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusResponse.kt new file mode 100644 index 00000000..4315825e --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusResponse.kt @@ -0,0 +1,415 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ItemCreateStatusResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val isArchived: JsonField, + private val overrideAddedAt: JsonField, + private val queueItemId: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("is_archived") + @ExcludeMissing + isArchived: JsonField = JsonMissing.of(), + @JsonProperty("override_added_at") + @ExcludeMissing + overrideAddedAt: JsonField = JsonMissing.of(), + @JsonProperty("queue_item_id") + @ExcludeMissing + queueItemId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(isArchived, overrideAddedAt, queueItemId, status, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isArchived(): Optional = isArchived.getOptional("is_archived") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun overrideAddedAt(): Optional = overrideAddedAt.getOptional("override_added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun queueItemId(): Optional = queueItemId.getOptional("queue_item_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [isArchived]. + * + * Unlike [isArchived], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_archived") @ExcludeMissing fun _isArchived(): JsonField = isArchived + + /** + * Returns the raw JSON value of [overrideAddedAt]. + * + * Unlike [overrideAddedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("override_added_at") + @ExcludeMissing + fun _overrideAddedAt(): JsonField = overrideAddedAt + + /** + * Returns the raw JSON value of [queueItemId]. + * + * Unlike [queueItemId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_item_id") + @ExcludeMissing + fun _queueItemId(): JsonField = queueItemId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @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 [ItemCreateStatusResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemCreateStatusResponse]. */ + class Builder internal constructor() { + + private var isArchived: JsonField = JsonMissing.of() + private var overrideAddedAt: JsonField = JsonMissing.of() + private var queueItemId: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemCreateStatusResponse: ItemCreateStatusResponse) = apply { + isArchived = itemCreateStatusResponse.isArchived + overrideAddedAt = itemCreateStatusResponse.overrideAddedAt + queueItemId = itemCreateStatusResponse.queueItemId + status = itemCreateStatusResponse.status + additionalProperties = itemCreateStatusResponse.additionalProperties.toMutableMap() + } + + fun isArchived(isArchived: Boolean) = isArchived(JsonField.of(isArchived)) + + /** + * Sets [Builder.isArchived] to an arbitrary JSON value. + * + * You should usually call [Builder.isArchived] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isArchived(isArchived: JsonField) = apply { this.isArchived = isArchived } + + fun overrideAddedAt(overrideAddedAt: String) = + overrideAddedAt(JsonField.of(overrideAddedAt)) + + /** + * Sets [Builder.overrideAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.overrideAddedAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun overrideAddedAt(overrideAddedAt: JsonField) = apply { + this.overrideAddedAt = overrideAddedAt + } + + fun queueItemId(queueItemId: String) = queueItemId(JsonField.of(queueItemId)) + + /** + * Sets [Builder.queueItemId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueItemId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun queueItemId(queueItemId: JsonField) = apply { this.queueItemId = queueItemId } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + 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 [ItemCreateStatusResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemCreateStatusResponse = + ItemCreateStatusResponse( + isArchived, + overrideAddedAt, + queueItemId, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemCreateStatusResponse = apply { + if (validated) { + return@apply + } + + isArchived() + overrideAddedAt() + queueItemId() + status().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (isArchived.asKnown().isPresent) 1 else 0) + + (if (overrideAddedAt.asKnown().isPresent) 1 else 0) + + (if (queueItemId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VIEWED = of("viewed") + + @JvmField val COMPLETED = of("completed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + VIEWED, + COMPLETED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VIEWED, + COMPLETED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VIEWED -> Value.VIEWED + COMPLETED -> Value.COMPLETED + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VIEWED -> Known.VIEWED + COMPLETED -> Known.COMPLETED + else -> throw LangChainInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 Status && 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 ItemCreateStatusResponse && + isArchived == other.isArchived && + overrideAddedAt == other.overrideAddedAt && + queueItemId == other.queueItemId && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(isArchived, overrideAddedAt, queueItemId, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemCreateStatusResponse{isArchived=$isArchived, overrideAddedAt=$overrideAddedAt, queueItemId=$queueItemId, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllParams.kt new file mode 100644 index 00000000..a18de7de --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllParams.kt @@ -0,0 +1,441 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkKnown +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Remove RUN or THREAD items from a single annotation queue by membership ID. */ +class ItemDeleteAllParams +private constructor( + private val queueId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun itemIds(): Optional> = body.itemIds() + + /** + * Returns the raw JSON value of [itemIds]. + * + * Unlike [itemIds], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _itemIds(): JsonField> = body._itemIds() + + 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(): ItemDeleteAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ItemDeleteAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemDeleteAllParams]. */ + class Builder internal constructor() { + + private var queueId: 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(itemDeleteAllParams: ItemDeleteAllParams) = apply { + queueId = itemDeleteAllParams.queueId + body = itemDeleteAllParams.body.toBuilder() + additionalHeaders = itemDeleteAllParams.additionalHeaders.toBuilder() + additionalQueryParams = itemDeleteAllParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.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: + * - [itemIds] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun itemIds(itemIds: List) = apply { body.itemIds(itemIds) } + + /** + * Sets [Builder.itemIds] to an arbitrary JSON value. + * + * You should usually call [Builder.itemIds] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun itemIds(itemIds: JsonField>) = apply { body.itemIds(itemIds) } + + /** + * Adds a single [String] to [itemIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItemId(itemId: String) = apply { body.addItemId(itemId) } + + 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 [ItemDeleteAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemDeleteAllParams = + ItemDeleteAllParams( + queueId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val itemIds: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("item_ids") + @ExcludeMissing + itemIds: JsonField> = JsonMissing.of() + ) : this(itemIds, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun itemIds(): Optional> = itemIds.getOptional("item_ids") + + /** + * Returns the raw JSON value of [itemIds]. + * + * Unlike [itemIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_ids") @ExcludeMissing fun _itemIds(): JsonField> = itemIds + + @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 itemIds: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + itemIds = body.itemIds.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun itemIds(itemIds: List) = itemIds(JsonField.of(itemIds)) + + /** + * Sets [Builder.itemIds] to an arbitrary JSON value. + * + * You should usually call [Builder.itemIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun itemIds(itemIds: JsonField>) = apply { + this.itemIds = itemIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [itemIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItemId(itemId: String) = apply { + itemIds = + (itemIds ?: JsonField.of(mutableListOf())).also { + checkKnown("itemIds", it).add(itemId) + } + } + + 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( + (itemIds ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + itemIds() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 = (itemIds.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + itemIds == other.itemIds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(itemIds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{itemIds=$itemIds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemDeleteAllParams && + queueId == other.queueId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ItemDeleteAllParams{queueId=$queueId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllResponse.kt new file mode 100644 index 00000000..fa0943af --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllResponse.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Objects + +class ItemDeleteAllResponse +@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 [ItemDeleteAllResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemDeleteAllResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemDeleteAllResponse: ItemDeleteAllResponse) = apply { + additionalProperties = itemDeleteAllResponse.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 [ItemDeleteAllResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemDeleteAllResponse = + ItemDeleteAllResponse(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemDeleteAllResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemDeleteAllResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ItemDeleteAllResponse{additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPage.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPage.kt new file mode 100644 index 00000000..4c0a4506 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPage.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.AutoPager +import com.langchain.smith.core.Page +import com.langchain.smith.core.checkRequired +import com.langchain.smith.services.blocking.annotationqueues.ItemService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see ItemService.list */ +class ItemListPage +private constructor( + private val service: ItemService, + private val params: ItemListParams, + private val response: ItemListPageResponse, +) : Page { + + /** + * Delegates to [ItemListPageResponse], but gracefully handles missing data. + * + * @see ItemListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [ItemListPageResponse], but gracefully handles missing data. + * + * @see ItemListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): ItemListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): ItemListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): ItemListParams = params + + /** The response that this page was parsed from. */ + fun response(): ItemListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListPage]. */ + class Builder internal constructor() { + + private var service: ItemService? = null + private var params: ItemListParams? = null + private var response: ItemListPageResponse? = null + + @JvmSynthetic + internal fun from(itemListPage: ItemListPage) = apply { + service = itemListPage.service + params = itemListPage.params + response = itemListPage.response + } + + fun service(service: ItemService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: ItemListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: ItemListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [ItemListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemListPage = + ItemListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = "ItemListPage{service=$service, params=$params, response=$response}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageAsync.kt new file mode 100644 index 00000000..ae6dc676 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageAsync.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.AutoPagerAsync +import com.langchain.smith.core.PageAsync +import com.langchain.smith.core.checkRequired +import com.langchain.smith.services.async.annotationqueues.ItemServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see ItemServiceAsync.list */ +class ItemListPageAsync +private constructor( + private val service: ItemServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: ItemListParams, + private val response: ItemListPageResponse, +) : PageAsync { + + /** + * Delegates to [ItemListPageResponse], but gracefully handles missing data. + * + * @see ItemListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [ItemListPageResponse], but gracefully handles missing data. + * + * @see ItemListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): ItemListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): ItemListParams = params + + /** The response that this page was parsed from. */ + fun response(): ItemListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListPageAsync]. */ + class Builder internal constructor() { + + private var service: ItemServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: ItemListParams? = null + private var response: ItemListPageResponse? = null + + @JvmSynthetic + internal fun from(itemListPageAsync: ItemListPageAsync) = apply { + service = itemListPageAsync.service + streamHandlerExecutor = itemListPageAsync.streamHandlerExecutor + params = itemListPageAsync.params + response = itemListPageAsync.response + } + + fun service(service: ItemServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: ItemListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: ItemListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [ItemListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemListPageAsync = + ItemListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "ItemListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageResponse.kt new file mode 100644 index 00000000..95a1d030 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageResponse.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.checkKnown +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ItemListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val nextCursor: JsonField, + private val previousCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + @JsonProperty("previous_cursor") + @ExcludeMissing + previousCursor: JsonField = JsonMissing.of(), + ) : this(items, nextCursor, previousCursor, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("items") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previousCursor(): Optional = previousCursor.getOptional("previous_cursor") + + /** + * 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 + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + /** + * Returns the raw JSON value of [previousCursor]. + * + * Unlike [previousCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("previous_cursor") + @ExcludeMissing + fun _previousCursor(): JsonField = previousCursor + + @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 [ItemListPageResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListPageResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var nextCursor: JsonField = JsonMissing.of() + private var previousCursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemListPageResponse: ItemListPageResponse) = apply { + items = itemListPageResponse.items.map { it.toMutableList() } + nextCursor = itemListPageResponse.nextCursor + previousCursor = itemListPageResponse.previousCursor + additionalProperties = itemListPageResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [ItemListResponse] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: ItemListResponse) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + fun previousCursor(previousCursor: String) = previousCursor(JsonField.of(previousCursor)) + + /** + * Sets [Builder.previousCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.previousCursor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun previousCursor(previousCursor: JsonField) = apply { + this.previousCursor = previousCursor + } + + 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 [ItemListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemListPageResponse = + ItemListPageResponse( + (items ?: JsonMissing.of()).map { it.toImmutable() }, + nextCursor, + previousCursor, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemListPageResponse = apply { + if (validated) { + return@apply + } + + items().ifPresent { it.forEach { it.validate() } } + nextCursor() + previousCursor() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + (if (previousCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemListPageResponse && + items == other.items && + nextCursor == other.nextCursor && + previousCursor == other.previousCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(items, nextCursor, previousCursor, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemListPageResponse{items=$items, nextCursor=$nextCursor, previousCursor=$previousCursor, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListParams.kt new file mode 100644 index 00000000..97ff14cd --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListParams.kt @@ -0,0 +1,729 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.annotation.JsonCreator +import com.langchain.smith.core.Enum +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * List RUN and THREAD items in a single annotation queue for one review status section, with opaque + * cursor pagination. Optional item_type=RUN|THREAD filters the page. direction=backward returns + * items before the supplied cursor. Response is membership metadata only (no nested run/thread + * store payloads). status=archived returns items in annotation_queue_runs_archive (queue completion + * rule met), not merely items the caller personally marked completed. + */ +class ItemListParams +private constructor( + private val queueId: String?, + private val status: Status, + private val cursor: String?, + private val direction: Direction?, + private val itemType: ItemType?, + private val pageSize: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** Review section: needs_my_review, needs_others_review, or archived */ + fun status(): Status = status + + /** Opaque pagination cursor */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Pagination direction. backward requires cursor */ + fun direction(): Optional = Optional.ofNullable(direction) + + /** Filter to RUN or THREAD */ + fun itemType(): Optional = Optional.ofNullable(itemType) + + /** Page size (max 100) */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** 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 { + + /** + * Returns a mutable builder for constructing an instance of [ItemListParams]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var status: Status? = null + private var cursor: String? = null + private var direction: Direction? = null + private var itemType: ItemType? = null + private var pageSize: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(itemListParams: ItemListParams) = apply { + queueId = itemListParams.queueId + status = itemListParams.status + cursor = itemListParams.cursor + direction = itemListParams.direction + itemType = itemListParams.itemType + pageSize = itemListParams.pageSize + additionalHeaders = itemListParams.additionalHeaders.toBuilder() + additionalQueryParams = itemListParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + /** Review section: needs_my_review, needs_others_review, or archived */ + fun status(status: Status) = apply { this.status = status } + + /** Opaque pagination cursor */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** Pagination direction. backward requires cursor */ + fun direction(direction: Direction?) = apply { this.direction = direction } + + /** Alias for calling [Builder.direction] with `direction.orElse(null)`. */ + fun direction(direction: Optional) = direction(direction.getOrNull()) + + /** Filter to RUN or THREAD */ + fun itemType(itemType: ItemType?) = apply { this.itemType = itemType } + + /** Alias for calling [Builder.itemType] with `itemType.orElse(null)`. */ + fun itemType(itemType: Optional) = itemType(itemType.getOrNull()) + + /** Page size (max 100) */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ItemListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemListParams = + ItemListParams( + queueId, + checkRequired("status", status), + cursor, + direction, + itemType, + pageSize, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("status", status.toString()) + cursor?.let { put("cursor", it) } + direction?.let { put("direction", it.toString()) } + itemType?.let { put("item_type", it.toString()) } + pageSize?.let { put("page_size", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Review section: needs_my_review, needs_others_review, or archived */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NEEDS_MY_REVIEW = of("needs_my_review") + + @JvmField val NEEDS_OTHERS_REVIEW = of("needs_others_review") + + @JvmField val ARCHIVED = of("archived") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + ARCHIVED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + ARCHIVED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NEEDS_MY_REVIEW -> Value.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Value.NEEDS_OTHERS_REVIEW + ARCHIVED -> Value.ARCHIVED + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NEEDS_MY_REVIEW -> Known.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Known.NEEDS_OTHERS_REVIEW + ARCHIVED -> Known.ARCHIVED + else -> throw LangChainInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Pagination direction. backward requires cursor */ + class Direction @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 FORWARD = of("forward") + + @JvmField val BACKWARD = of("backward") + + @JvmStatic fun of(value: String) = Direction(JsonField.of(value)) + } + + /** An enum containing [Direction]'s known values. */ + enum class Known { + FORWARD, + BACKWARD, + } + + /** + * An enum containing [Direction]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Direction] 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 { + FORWARD, + BACKWARD, + /** + * An enum member indicating that [Direction] 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) { + FORWARD -> Value.FORWARD + BACKWARD -> Value.BACKWARD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FORWARD -> Known.FORWARD + BACKWARD -> Known.BACKWARD + else -> throw LangChainInvalidDataException("Unknown Direction: $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 LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Direction = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 Direction && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Filter to RUN or THREAD */ + class ItemType @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 RUN = of("RUN") + + @JvmField val THREAD = of("THREAD") + + @JvmStatic fun of(value: String) = ItemType(JsonField.of(value)) + } + + /** An enum containing [ItemType]'s known values. */ + enum class Known { + RUN, + THREAD, + } + + /** + * An enum containing [ItemType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ItemType] 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 { + RUN, + THREAD, + /** An enum member indicating that [ItemType] 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) { + RUN -> Value.RUN + THREAD -> Value.THREAD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + THREAD -> Known.THREAD + else -> throw LangChainInvalidDataException("Unknown ItemType: $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 LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemType && 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 ItemListParams && + queueId == other.queueId && + status == other.status && + cursor == other.cursor && + direction == other.direction && + itemType == other.itemType && + pageSize == other.pageSize && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + queueId, + status, + cursor, + direction, + itemType, + pageSize, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ItemListParams{queueId=$queueId, status=$status, cursor=$cursor, direction=$direction, itemType=$itemType, pageSize=$pageSize, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListResponse.kt new file mode 100644 index 00000000..d081e650 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListResponse.kt @@ -0,0 +1,782 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.checkKnown +import com.langchain.smith.core.toImmutable +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ItemListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val addedAt: JsonField, + private val completedBy: JsonField>, + private val effectiveAddedAt: JsonField, + private val itemType: JsonField, + private val lastReviewedTime: JsonField, + private val queueId: JsonField, + private val reservedBy: JsonField>, + private val runId: JsonField, + private val sessionId: JsonField, + private val sourceProposedExampleId: JsonField, + private val startTime: JsonField, + private val threadId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("added_at") @ExcludeMissing addedAt: JsonField = JsonMissing.of(), + @JsonProperty("completed_by") + @ExcludeMissing + completedBy: JsonField> = JsonMissing.of(), + @JsonProperty("effective_added_at") + @ExcludeMissing + effectiveAddedAt: JsonField = JsonMissing.of(), + @JsonProperty("item_type") @ExcludeMissing itemType: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + @JsonProperty("queue_id") @ExcludeMissing queueId: JsonField = JsonMissing.of(), + @JsonProperty("reserved_by") + @ExcludeMissing + reservedBy: JsonField> = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + sourceProposedExampleId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), + @JsonProperty("thread_id") @ExcludeMissing threadId: JsonField = JsonMissing.of(), + ) : this( + id, + addedAt, + completedBy, + effectiveAddedAt, + itemType, + lastReviewedTime, + queueId, + reservedBy, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun completedBy(): Optional> = completedBy.getOptional("completed_by") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun effectiveAddedAt(): Optional = effectiveAddedAt.getOptional("effective_added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun itemType(): Optional = itemType.getOptional("item_type") + + /** + * LastReviewedTime is always present on the wire (null until reviewed). + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = lastReviewedTime.getOptional("last_reviewed_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun queueId(): Optional = queueId.getOptional("queue_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reservedBy(): Optional> = reservedBy.getOptional("reserved_by") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun runId(): Optional = runId.getOptional("run_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceProposedExampleId(): Optional = + sourceProposedExampleId.getOptional("source_proposed_example_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun threadId(): Optional = threadId.getOptional("thread_id") + + /** + * 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 [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [completedBy]. + * + * Unlike [completedBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("completed_by") + @ExcludeMissing + fun _completedBy(): JsonField> = completedBy + + /** + * Returns the raw JSON value of [effectiveAddedAt]. + * + * Unlike [effectiveAddedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("effective_added_at") + @ExcludeMissing + fun _effectiveAddedAt(): JsonField = effectiveAddedAt + + /** + * Returns the raw JSON value of [itemType]. + * + * Unlike [itemType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_type") @ExcludeMissing fun _itemType(): JsonField = itemType + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + /** + * Returns the raw JSON value of [queueId]. + * + * Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_id") @ExcludeMissing fun _queueId(): JsonField = queueId + + /** + * Returns the raw JSON value of [reservedBy]. + * + * Unlike [reservedBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reserved_by") + @ExcludeMissing + fun _reservedBy(): JsonField> = reservedBy + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField = runId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [sourceProposedExampleId]. + * + * Unlike [sourceProposedExampleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + fun _sourceProposedExampleId(): JsonField = sourceProposedExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") @ExcludeMissing fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId + + @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 [ItemListResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var addedAt: JsonField = JsonMissing.of() + private var completedBy: JsonField>? = null + private var effectiveAddedAt: JsonField = JsonMissing.of() + private var itemType: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var queueId: JsonField = JsonMissing.of() + private var reservedBy: JsonField>? = null + private var runId: JsonField = JsonMissing.of() + private var sessionId: JsonField = JsonMissing.of() + private var sourceProposedExampleId: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var threadId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemListResponse: ItemListResponse) = apply { + id = itemListResponse.id + addedAt = itemListResponse.addedAt + completedBy = itemListResponse.completedBy.map { it.toMutableList() } + effectiveAddedAt = itemListResponse.effectiveAddedAt + itemType = itemListResponse.itemType + lastReviewedTime = itemListResponse.lastReviewedTime + queueId = itemListResponse.queueId + reservedBy = itemListResponse.reservedBy.map { it.toMutableList() } + runId = itemListResponse.runId + sessionId = itemListResponse.sessionId + sourceProposedExampleId = itemListResponse.sourceProposedExampleId + startTime = itemListResponse.startTime + threadId = itemListResponse.threadId + additionalProperties = itemListResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun addedAt(addedAt: String) = addedAt(JsonField.of(addedAt)) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun completedBy(completedBy: List) = completedBy(JsonField.of(completedBy)) + + /** + * Sets [Builder.completedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.completedBy] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun completedBy(completedBy: JsonField>) = apply { + this.completedBy = completedBy.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.completedBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCompletedBy(completedBy: String) = apply { + this.completedBy = + (this.completedBy ?: JsonField.of(mutableListOf())).also { + checkKnown("completedBy", it).add(completedBy) + } + } + + fun effectiveAddedAt(effectiveAddedAt: String) = + effectiveAddedAt(JsonField.of(effectiveAddedAt)) + + /** + * Sets [Builder.effectiveAddedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.effectiveAddedAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun effectiveAddedAt(effectiveAddedAt: JsonField) = apply { + this.effectiveAddedAt = effectiveAddedAt + } + + fun itemType(itemType: ItemType) = itemType(JsonField.of(itemType)) + + /** + * Sets [Builder.itemType] to an arbitrary JSON value. + * + * You should usually call [Builder.itemType] with a well-typed [ItemType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun itemType(itemType: JsonField) = apply { this.itemType = itemType } + + /** LastReviewedTime is always present on the wire (null until reviewed). */ + fun lastReviewedTime(lastReviewedTime: String) = + lastReviewedTime(JsonField.of(lastReviewedTime)) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + fun queueId(queueId: String) = queueId(JsonField.of(queueId)) + + /** + * Sets [Builder.queueId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun queueId(queueId: JsonField) = apply { this.queueId = queueId } + + fun reservedBy(reservedBy: List) = reservedBy(JsonField.of(reservedBy)) + + /** + * Sets [Builder.reservedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.reservedBy] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reservedBy(reservedBy: JsonField>) = apply { + this.reservedBy = reservedBy.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.reservedBy]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addReservedBy(reservedBy: String) = apply { + this.reservedBy = + (this.reservedBy ?: JsonField.of(mutableListOf())).also { + checkKnown("reservedBy", it).add(reservedBy) + } + } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun sourceProposedExampleId(sourceProposedExampleId: String) = + sourceProposedExampleId(JsonField.of(sourceProposedExampleId)) + + /** + * Sets [Builder.sourceProposedExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceProposedExampleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sourceProposedExampleId(sourceProposedExampleId: JsonField) = apply { + this.sourceProposedExampleId = sourceProposedExampleId + } + + fun startTime(startTime: String) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startTime(startTime: JsonField) = apply { this.startTime = startTime } + + fun threadId(threadId: String) = threadId(JsonField.of(threadId)) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun threadId(threadId: JsonField) = apply { this.threadId = threadId } + + 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 [ItemListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemListResponse = + ItemListResponse( + id, + addedAt, + (completedBy ?: JsonMissing.of()).map { it.toImmutable() }, + effectiveAddedAt, + itemType, + lastReviewedTime, + queueId, + (reservedBy ?: JsonMissing.of()).map { it.toImmutable() }, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemListResponse = apply { + if (validated) { + return@apply + } + + id() + addedAt() + completedBy() + effectiveAddedAt() + itemType().ifPresent { it.validate() } + lastReviewedTime() + queueId() + reservedBy() + runId() + sessionId() + sourceProposedExampleId() + startTime() + threadId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (addedAt.asKnown().isPresent) 1 else 0) + + (completedBy.asKnown().getOrNull()?.size ?: 0) + + (if (effectiveAddedAt.asKnown().isPresent) 1 else 0) + + (itemType.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + (if (queueId.asKnown().isPresent) 1 else 0) + + (reservedBy.asKnown().getOrNull()?.size ?: 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sourceProposedExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + class ItemType @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 RUN = of("RUN") + + @JvmField val THREAD = of("THREAD") + + @JvmStatic fun of(value: String) = ItemType(JsonField.of(value)) + } + + /** An enum containing [ItemType]'s known values. */ + enum class Known { + RUN, + THREAD, + } + + /** + * An enum containing [ItemType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ItemType] 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 { + RUN, + THREAD, + /** An enum member indicating that [ItemType] 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) { + RUN -> Value.RUN + THREAD -> Value.THREAD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + THREAD -> Known.THREAD + else -> throw LangChainInvalidDataException("Unknown ItemType: $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 LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemType && 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 ItemListResponse && + id == other.id && + addedAt == other.addedAt && + completedBy == other.completedBy && + effectiveAddedAt == other.effectiveAddedAt && + itemType == other.itemType && + lastReviewedTime == other.lastReviewedTime && + queueId == other.queueId && + reservedBy == other.reservedBy && + runId == other.runId && + sessionId == other.sessionId && + sourceProposedExampleId == other.sourceProposedExampleId && + startTime == other.startTime && + threadId == other.threadId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + addedAt, + completedBy, + effectiveAddedAt, + itemType, + lastReviewedTime, + queueId, + reservedBy, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemListResponse{id=$id, addedAt=$addedAt, completedBy=$completedBy, effectiveAddedAt=$effectiveAddedAt, itemType=$itemType, lastReviewedTime=$lastReviewedTime, queueId=$queueId, reservedBy=$reservedBy, runId=$runId, sessionId=$sessionId, sourceProposedExampleId=$sourceProposedExampleId, startTime=$startTime, threadId=$threadId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountParams.kt new file mode 100644 index 00000000..83cafb55 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountParams.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returns the number of annotation queue items for the requested reviewer-specific or archived + * bucket. + */ +class ItemRetrieveCountParams +private constructor( + private val queueId: String?, + private val status: String, + private val endTime: String?, + private val startTime: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): Optional = Optional.ofNullable(queueId) + + /** Count bucket: all, needs_my_review, needs_others_review, or archived. */ + fun status(): String = status + + /** Exclusive upper bound for archived item timestamp */ + fun endTime(): Optional = Optional.ofNullable(endTime) + + /** Exclusive lower bound for archived item timestamp */ + fun startTime(): Optional = Optional.ofNullable(startTime) + + /** 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 { + + /** + * Returns a mutable builder for constructing an instance of [ItemRetrieveCountParams]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemRetrieveCountParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var status: String? = null + private var endTime: String? = null + private var startTime: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(itemRetrieveCountParams: ItemRetrieveCountParams) = apply { + queueId = itemRetrieveCountParams.queueId + status = itemRetrieveCountParams.status + endTime = itemRetrieveCountParams.endTime + startTime = itemRetrieveCountParams.startTime + additionalHeaders = itemRetrieveCountParams.additionalHeaders.toBuilder() + additionalQueryParams = itemRetrieveCountParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String?) = apply { this.queueId = queueId } + + /** Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */ + fun queueId(queueId: Optional) = queueId(queueId.getOrNull()) + + /** Count bucket: all, needs_my_review, needs_others_review, or archived. */ + fun status(status: String) = apply { this.status = status } + + /** Exclusive upper bound for archived item timestamp */ + fun endTime(endTime: String?) = apply { this.endTime = endTime } + + /** Alias for calling [Builder.endTime] with `endTime.orElse(null)`. */ + fun endTime(endTime: Optional) = endTime(endTime.getOrNull()) + + /** Exclusive lower bound for archived item timestamp */ + fun startTime(startTime: String?) = apply { this.startTime = startTime } + + /** Alias for calling [Builder.startTime] with `startTime.orElse(null)`. */ + fun startTime(startTime: Optional) = startTime(startTime.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ItemRetrieveCountParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemRetrieveCountParams = + ItemRetrieveCountParams( + queueId, + checkRequired("status", status), + endTime, + startTime, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("status", status) + endTime?.let { put("end_time", it) } + startTime?.let { put("start_time", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemRetrieveCountParams && + queueId == other.queueId && + status == other.status && + endTime == other.endTime && + startTime == other.startTime && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, status, endTime, startTime, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ItemRetrieveCountParams{queueId=$queueId, status=$status, endTime=$endTime, startTime=$startTime, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountResponse.kt new file mode 100644 index 00000000..ca0df9e8 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountResponse.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class ItemRetrieveCountResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of() + ) : this(count, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + @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 [ItemRetrieveCountResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemRetrieveCountResponse]. */ + class Builder internal constructor() { + + private var count: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemRetrieveCountResponse: ItemRetrieveCountResponse) = apply { + count = itemRetrieveCountResponse.count + additionalProperties = itemRetrieveCountResponse.additionalProperties.toMutableMap() + } + + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + 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 [ItemRetrieveCountResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemRetrieveCountResponse = + ItemRetrieveCountResponse(count, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemRetrieveCountResponse = apply { + if (validated) { + return@apply + } + + count() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (count.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemRetrieveCountResponse && + count == other.count && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemRetrieveCountResponse{count=$count, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementParams.kt new file mode 100644 index 00000000..bcbc4ea3 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementParams.kt @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Resolve a RUN or THREAD item to its current review section and zero-based position for deep + * linking. + */ +class ItemRetrievePlacementParams +private constructor( + private val queueId: String, + private val itemId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): String = queueId + + fun itemId(): Optional = Optional.ofNullable(itemId) + + /** 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 { + + /** + * Returns a mutable builder for constructing an instance of [ItemRetrievePlacementParams]. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemRetrievePlacementParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var itemId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(itemRetrievePlacementParams: ItemRetrievePlacementParams) = apply { + queueId = itemRetrievePlacementParams.queueId + itemId = itemRetrievePlacementParams.itemId + additionalHeaders = itemRetrievePlacementParams.additionalHeaders.toBuilder() + additionalQueryParams = itemRetrievePlacementParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String) = apply { this.queueId = queueId } + + fun itemId(itemId: String?) = apply { this.itemId = itemId } + + /** Alias for calling [Builder.itemId] with `itemId.orElse(null)`. */ + fun itemId(itemId: Optional) = itemId(itemId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ItemRetrievePlacementParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemRetrievePlacementParams = + ItemRetrievePlacementParams( + checkRequired("queueId", queueId), + itemId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId + 1 -> itemId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemRetrievePlacementParams && + queueId == other.queueId && + itemId == other.itemId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, itemId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ItemRetrievePlacementParams{queueId=$queueId, itemId=$itemId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementResponse.kt new file mode 100644 index 00000000..57e2e503 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementResponse.kt @@ -0,0 +1,545 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ItemRetrievePlacementResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val cursor: JsonField, + private val itemType: JsonField, + private val position: JsonField, + private val section: JsonField
, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("item_type") @ExcludeMissing itemType: JsonField = JsonMissing.of(), + @JsonProperty("position") @ExcludeMissing position: JsonField = JsonMissing.of(), + @JsonProperty("section") @ExcludeMissing section: JsonField
= JsonMissing.of(), + ) : this(cursor, itemType, position, section, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun itemType(): Optional = itemType.getOptional("item_type") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun position(): Optional = position.getOptional("position") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun section(): Optional
= section.getOptional("section") + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [itemType]. + * + * Unlike [itemType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_type") @ExcludeMissing fun _itemType(): JsonField = itemType + + /** + * Returns the raw JSON value of [position]. + * + * Unlike [position], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("position") @ExcludeMissing fun _position(): JsonField = position + + /** + * Returns the raw JSON value of [section]. + * + * Unlike [section], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("section") @ExcludeMissing fun _section(): JsonField
= section + + @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 + * [ItemRetrievePlacementResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemRetrievePlacementResponse]. */ + class Builder internal constructor() { + + private var cursor: JsonField = JsonMissing.of() + private var itemType: JsonField = JsonMissing.of() + private var position: JsonField = JsonMissing.of() + private var section: JsonField
= JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemRetrievePlacementResponse: ItemRetrievePlacementResponse) = apply { + cursor = itemRetrievePlacementResponse.cursor + itemType = itemRetrievePlacementResponse.itemType + position = itemRetrievePlacementResponse.position + section = itemRetrievePlacementResponse.section + additionalProperties = itemRetrievePlacementResponse.additionalProperties.toMutableMap() + } + + fun cursor(cursor: String) = cursor(JsonField.of(cursor)) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun itemType(itemType: ItemType) = itemType(JsonField.of(itemType)) + + /** + * Sets [Builder.itemType] to an arbitrary JSON value. + * + * You should usually call [Builder.itemType] with a well-typed [ItemType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun itemType(itemType: JsonField) = apply { this.itemType = itemType } + + fun position(position: Long) = position(JsonField.of(position)) + + /** + * Sets [Builder.position] to an arbitrary JSON value. + * + * You should usually call [Builder.position] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun position(position: JsonField) = apply { this.position = position } + + fun section(section: Section) = section(JsonField.of(section)) + + /** + * Sets [Builder.section] to an arbitrary JSON value. + * + * You should usually call [Builder.section] with a well-typed [Section] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun section(section: JsonField
) = apply { this.section = section } + + 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 [ItemRetrievePlacementResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemRetrievePlacementResponse = + ItemRetrievePlacementResponse( + cursor, + itemType, + position, + section, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemRetrievePlacementResponse = apply { + if (validated) { + return@apply + } + + cursor() + itemType().ifPresent { it.validate() } + position() + section().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (cursor.asKnown().isPresent) 1 else 0) + + (itemType.asKnown().getOrNull()?.validity() ?: 0) + + (if (position.asKnown().isPresent) 1 else 0) + + (section.asKnown().getOrNull()?.validity() ?: 0) + + class ItemType @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 RUN = of("RUN") + + @JvmField val THREAD = of("THREAD") + + @JvmStatic fun of(value: String) = ItemType(JsonField.of(value)) + } + + /** An enum containing [ItemType]'s known values. */ + enum class Known { + RUN, + THREAD, + } + + /** + * An enum containing [ItemType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ItemType] 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 { + RUN, + THREAD, + /** An enum member indicating that [ItemType] 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) { + RUN -> Value.RUN + THREAD -> Value.THREAD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + THREAD -> Known.THREAD + else -> throw LangChainInvalidDataException("Unknown ItemType: $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 LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Section @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 NEEDS_MY_REVIEW = of("needs_my_review") + + @JvmField val NEEDS_OTHERS_REVIEW = of("needs_others_review") + + @JvmField val ARCHIVED = of("archived") + + @JvmStatic fun of(value: String) = Section(JsonField.of(value)) + } + + /** An enum containing [Section]'s known values. */ + enum class Known { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + ARCHIVED, + } + + /** + * An enum containing [Section]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Section] 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 { + NEEDS_MY_REVIEW, + NEEDS_OTHERS_REVIEW, + ARCHIVED, + /** An enum member indicating that [Section] 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) { + NEEDS_MY_REVIEW -> Value.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Value.NEEDS_OTHERS_REVIEW + ARCHIVED -> Value.ARCHIVED + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NEEDS_MY_REVIEW -> Known.NEEDS_MY_REVIEW + NEEDS_OTHERS_REVIEW -> Known.NEEDS_OTHERS_REVIEW + ARCHIVED -> Known.ARCHIVED + else -> throw LangChainInvalidDataException("Unknown Section: $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 LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Section = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 Section && 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 ItemRetrievePlacementResponse && + cursor == other.cursor && + itemType == other.itemType && + position == other.position && + section == other.section && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cursor, itemType, position, section, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemRetrievePlacementResponse{cursor=$cursor, itemType=$itemType, position=$position, section=$section, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateParams.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateParams.kt new file mode 100644 index 00000000..6683a75f --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateParams.kt @@ -0,0 +1,518 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.Params +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.http.Headers +import com.langchain.smith.core.http.QueryParams +import com.langchain.smith.errors.LangChainInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Partially update membership fields (added_at, last_reviewed_time) for a single annotation queue + * item by membership id. Works for RUN and THREAD rows. Omit a field (or pass JSON null) to leave + * it unchanged. + */ +class ItemUpdateParams +private constructor( + private val queueId: String, + private val itemId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun queueId(): String = queueId + + fun itemId(): Optional = Optional.ofNullable(itemId) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addedAt(): Optional = body.addedAt() + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = body.lastReviewedTime() + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _addedAt(): JsonField = body._addedAt() + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _lastReviewedTime(): JsonField = body._lastReviewedTime() + + 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 { + + /** + * Returns a mutable builder for constructing an instance of [ItemUpdateParams]. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemUpdateParams]. */ + class Builder internal constructor() { + + private var queueId: String? = null + private var itemId: 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(itemUpdateParams: ItemUpdateParams) = apply { + queueId = itemUpdateParams.queueId + itemId = itemUpdateParams.itemId + body = itemUpdateParams.body.toBuilder() + additionalHeaders = itemUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = itemUpdateParams.additionalQueryParams.toBuilder() + } + + fun queueId(queueId: String) = apply { this.queueId = queueId } + + fun itemId(itemId: String?) = apply { this.itemId = itemId } + + /** Alias for calling [Builder.itemId] with `itemId.orElse(null)`. */ + fun itemId(itemId: Optional) = itemId(itemId.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: + * - [addedAt] + * - [lastReviewedTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun addedAt(addedAt: OffsetDateTime) = apply { body.addedAt(addedAt) } + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { body.addedAt(addedAt) } + + fun lastReviewedTime(lastReviewedTime: OffsetDateTime) = apply { + body.lastReviewedTime(lastReviewedTime) + } + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + body.lastReviewedTime(lastReviewedTime) + } + + 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 [ItemUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemUpdateParams = + ItemUpdateParams( + checkRequired("queueId", queueId), + itemId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> queueId + 1 -> itemId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addedAt: JsonField, + private val lastReviewedTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("added_at") + @ExcludeMissing + addedAt: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + ) : this(addedAt, lastReviewedTime, mutableMapOf()) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = + lastReviewedTime.getOptional("last_reviewed_time") + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") + @ExcludeMissing + fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + @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 addedAt: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + addedAt = body.addedAt + lastReviewedTime = body.lastReviewedTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun addedAt(addedAt: OffsetDateTime) = addedAt(JsonField.of(addedAt)) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun lastReviewedTime(lastReviewedTime: OffsetDateTime) = + lastReviewedTime(JsonField.of(lastReviewedTime)) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + 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(addedAt, lastReviewedTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + addedAt() + lastReviewedTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (addedAt.asKnown().isPresent) 1 else 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + addedAt == other.addedAt && + lastReviewedTime == other.lastReviewedTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(addedAt, lastReviewedTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{addedAt=$addedAt, lastReviewedTime=$lastReviewedTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemUpdateParams && + queueId == other.queueId && + itemId == other.itemId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(queueId, itemId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ItemUpdateParams{queueId=$queueId, itemId=$itemId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateResponse.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateResponse.kt new file mode 100644 index 00000000..6270f9f4 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateResponse.kt @@ -0,0 +1,634 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +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.langchain.smith.core.Enum +import com.langchain.smith.core.ExcludeMissing +import com.langchain.smith.core.JsonField +import com.langchain.smith.core.JsonMissing +import com.langchain.smith.core.JsonValue +import com.langchain.smith.errors.LangChainInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ItemUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val addedAt: JsonField, + private val itemType: JsonField, + private val lastReviewedTime: JsonField, + private val queueId: JsonField, + private val runId: JsonField, + private val sessionId: JsonField, + private val sourceProposedExampleId: JsonField, + private val startTime: JsonField, + private val threadId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("added_at") @ExcludeMissing addedAt: JsonField = JsonMissing.of(), + @JsonProperty("item_type") @ExcludeMissing itemType: JsonField = JsonMissing.of(), + @JsonProperty("last_reviewed_time") + @ExcludeMissing + lastReviewedTime: JsonField = JsonMissing.of(), + @JsonProperty("queue_id") @ExcludeMissing queueId: JsonField = JsonMissing.of(), + @JsonProperty("run_id") @ExcludeMissing runId: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + sourceProposedExampleId: JsonField = JsonMissing.of(), + @JsonProperty("start_time") @ExcludeMissing startTime: JsonField = JsonMissing.of(), + @JsonProperty("thread_id") @ExcludeMissing threadId: JsonField = JsonMissing.of(), + ) : this( + id, + addedAt, + itemType, + lastReviewedTime, + queueId, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + mutableMapOf(), + ) + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun addedAt(): Optional = addedAt.getOptional("added_at") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun itemType(): Optional = itemType.getOptional("item_type") + + /** + * LastReviewedTime is always present on the wire (null until reviewed). + * + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastReviewedTime(): Optional = lastReviewedTime.getOptional("last_reviewed_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun queueId(): Optional = queueId.getOptional("queue_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun runId(): Optional = runId.getOptional("run_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sourceProposedExampleId(): Optional = + sourceProposedExampleId.getOptional("source_proposed_example_id") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * @throws LangChainInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun threadId(): Optional = threadId.getOptional("thread_id") + + /** + * 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 [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [itemType]. + * + * Unlike [itemType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("item_type") @ExcludeMissing fun _itemType(): JsonField = itemType + + /** + * Returns the raw JSON value of [lastReviewedTime]. + * + * Unlike [lastReviewedTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_reviewed_time") + @ExcludeMissing + fun _lastReviewedTime(): JsonField = lastReviewedTime + + /** + * Returns the raw JSON value of [queueId]. + * + * Unlike [queueId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_id") @ExcludeMissing fun _queueId(): JsonField = queueId + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("run_id") @ExcludeMissing fun _runId(): JsonField = runId + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [sourceProposedExampleId]. + * + * Unlike [sourceProposedExampleId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_proposed_example_id") + @ExcludeMissing + fun _sourceProposedExampleId(): JsonField = sourceProposedExampleId + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") @ExcludeMissing fun _startTime(): JsonField = startTime + + /** + * Returns the raw JSON value of [threadId]. + * + * Unlike [threadId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thread_id") @ExcludeMissing fun _threadId(): JsonField = threadId + + @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 [ItemUpdateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemUpdateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var addedAt: JsonField = JsonMissing.of() + private var itemType: JsonField = JsonMissing.of() + private var lastReviewedTime: JsonField = JsonMissing.of() + private var queueId: JsonField = JsonMissing.of() + private var runId: JsonField = JsonMissing.of() + private var sessionId: JsonField = JsonMissing.of() + private var sourceProposedExampleId: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var threadId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemUpdateResponse: ItemUpdateResponse) = apply { + id = itemUpdateResponse.id + addedAt = itemUpdateResponse.addedAt + itemType = itemUpdateResponse.itemType + lastReviewedTime = itemUpdateResponse.lastReviewedTime + queueId = itemUpdateResponse.queueId + runId = itemUpdateResponse.runId + sessionId = itemUpdateResponse.sessionId + sourceProposedExampleId = itemUpdateResponse.sourceProposedExampleId + startTime = itemUpdateResponse.startTime + threadId = itemUpdateResponse.threadId + additionalProperties = itemUpdateResponse.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun addedAt(addedAt: String) = addedAt(JsonField.of(addedAt)) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun itemType(itemType: ItemType) = itemType(JsonField.of(itemType)) + + /** + * Sets [Builder.itemType] to an arbitrary JSON value. + * + * You should usually call [Builder.itemType] with a well-typed [ItemType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun itemType(itemType: JsonField) = apply { this.itemType = itemType } + + /** LastReviewedTime is always present on the wire (null until reviewed). */ + fun lastReviewedTime(lastReviewedTime: String) = + lastReviewedTime(JsonField.of(lastReviewedTime)) + + /** + * Sets [Builder.lastReviewedTime] to an arbitrary JSON value. + * + * You should usually call [Builder.lastReviewedTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastReviewedTime(lastReviewedTime: JsonField) = apply { + this.lastReviewedTime = lastReviewedTime + } + + fun queueId(queueId: String) = queueId(JsonField.of(queueId)) + + /** + * Sets [Builder.queueId] to an arbitrary JSON value. + * + * You should usually call [Builder.queueId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun queueId(queueId: JsonField) = apply { this.queueId = queueId } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun sourceProposedExampleId(sourceProposedExampleId: String) = + sourceProposedExampleId(JsonField.of(sourceProposedExampleId)) + + /** + * Sets [Builder.sourceProposedExampleId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceProposedExampleId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sourceProposedExampleId(sourceProposedExampleId: JsonField) = apply { + this.sourceProposedExampleId = sourceProposedExampleId + } + + fun startTime(startTime: String) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startTime(startTime: JsonField) = apply { this.startTime = startTime } + + fun threadId(threadId: String) = threadId(JsonField.of(threadId)) + + /** + * Sets [Builder.threadId] to an arbitrary JSON value. + * + * You should usually call [Builder.threadId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun threadId(threadId: JsonField) = apply { this.threadId = threadId } + + 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 [ItemUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ItemUpdateResponse = + ItemUpdateResponse( + id, + addedAt, + itemType, + lastReviewedTime, + queueId, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemUpdateResponse = apply { + if (validated) { + return@apply + } + + id() + addedAt() + itemType().ifPresent { it.validate() } + lastReviewedTime() + queueId() + runId() + sessionId() + sourceProposedExampleId() + startTime() + threadId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 (addedAt.asKnown().isPresent) 1 else 0) + + (itemType.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastReviewedTime.asKnown().isPresent) 1 else 0) + + (if (queueId.asKnown().isPresent) 1 else 0) + + (if (runId.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (sourceProposedExampleId.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (threadId.asKnown().isPresent) 1 else 0) + + class ItemType @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 RUN = of("RUN") + + @JvmField val THREAD = of("THREAD") + + @JvmStatic fun of(value: String) = ItemType(JsonField.of(value)) + } + + /** An enum containing [ItemType]'s known values. */ + enum class Known { + RUN, + THREAD, + } + + /** + * An enum containing [ItemType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ItemType] 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 { + RUN, + THREAD, + /** An enum member indicating that [ItemType] 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) { + RUN -> Value.RUN + THREAD -> Value.THREAD + 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 LangChainInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RUN -> Known.RUN + THREAD -> Known.THREAD + else -> throw LangChainInvalidDataException("Unknown ItemType: $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 LangChainInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LangChainInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LangChainInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ItemType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LangChainInvalidDataException) { + 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 ItemType && 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 ItemUpdateResponse && + id == other.id && + addedAt == other.addedAt && + itemType == other.itemType && + lastReviewedTime == other.lastReviewedTime && + queueId == other.queueId && + runId == other.runId && + sessionId == other.sessionId && + sourceProposedExampleId == other.sourceProposedExampleId && + startTime == other.startTime && + threadId == other.threadId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + addedAt, + itemType, + lastReviewedTime, + queueId, + runId, + sessionId, + sourceProposedExampleId, + startTime, + threadId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ItemUpdateResponse{id=$id, addedAt=$addedAt, itemType=$itemType, lastReviewedTime=$lastReviewedTime, queueId=$queueId, runId=$runId, sessionId=$sessionId, sourceProposedExampleId=$sourceProposedExampleId, startTime=$startTime, threadId=$threadId, additionalProperties=$additionalProperties}" +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsync.kt index 9c2d23b3..609f0cf3 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsync.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsync.kt @@ -28,6 +28,7 @@ import com.langchain.smith.models.annotationqueues.AnnotationQueueSizeSchema import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateParams import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateResponse import com.langchain.smith.models.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langchain.smith.services.async.annotationqueues.ItemServiceAsync import com.langchain.smith.services.async.annotationqueues.RunServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -48,6 +49,8 @@ interface AnnotationQueueServiceAsync { fun runs(): RunServiceAsync + fun items(): ItemServiceAsync + /** Get Annotation Queue */ fun retrieve(queueId: String): CompletableFuture = retrieve(queueId, AnnotationQueueRetrieveParams.none()) @@ -496,6 +499,8 @@ interface AnnotationQueueServiceAsync { fun runs(): RunServiceAsync.WithRawResponse + fun items(): ItemServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}`, but is * otherwise the same as [AnnotationQueueServiceAsync.retrieve]. diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncImpl.kt index 803db929..48d12a63 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/AnnotationQueueServiceAsyncImpl.kt @@ -40,6 +40,8 @@ import com.langchain.smith.models.annotationqueues.AnnotationQueueSizeSchema import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateParams import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateResponse import com.langchain.smith.models.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langchain.smith.services.async.annotationqueues.ItemServiceAsync +import com.langchain.smith.services.async.annotationqueues.ItemServiceAsyncImpl import com.langchain.smith.services.async.annotationqueues.RunServiceAsync import com.langchain.smith.services.async.annotationqueues.RunServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -55,6 +57,8 @@ internal constructor(private val clientOptions: ClientOptions) : AnnotationQueue private val runs: RunServiceAsync by lazy { RunServiceAsyncImpl(clientOptions) } + private val items: ItemServiceAsync by lazy { ItemServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): AnnotationQueueServiceAsync.WithRawResponse = withRawResponse override fun withOptions( @@ -64,6 +68,8 @@ internal constructor(private val clientOptions: ClientOptions) : AnnotationQueue override fun runs(): RunServiceAsync = runs + override fun items(): ItemServiceAsync = items + override fun retrieve( params: AnnotationQueueRetrieveParams, requestOptions: RequestOptions, @@ -165,6 +171,10 @@ internal constructor(private val clientOptions: ClientOptions) : AnnotationQueue RunServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val items: ItemServiceAsync.WithRawResponse by lazy { + ItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): AnnotationQueueServiceAsync.WithRawResponse = @@ -174,6 +184,8 @@ internal constructor(private val clientOptions: ClientOptions) : AnnotationQueue override fun runs(): RunServiceAsync.WithRawResponse = runs + override fun items(): ItemServiceAsync.WithRawResponse = items + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsync.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsync.kt new file mode 100644 index 00000000..ddb15ce1 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsync.kt @@ -0,0 +1,521 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.async.annotationqueues + +import com.langchain.smith.core.ClientOptions +import com.langchain.smith.core.RequestOptions +import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.models.annotationqueues.items.ItemCreateParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateResponse +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusResponse +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllParams +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllResponse +import com.langchain.smith.models.annotationqueues.items.ItemListPageAsync +import com.langchain.smith.models.annotationqueues.items.ItemListParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountResponse +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementResponse +import com.langchain.smith.models.annotationqueues.items.ItemUpdateParams +import com.langchain.smith.models.annotationqueues.items.ItemUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ItemServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemServiceAsync + + /** + * Add RUN or THREAD items to a single annotation queue. THREAD items require thread_id and + * session_id; RUN items require run_id, or source_proposed_example_id with lookup coordinates + * when applicable. + */ + fun create(queueId: String): CompletableFuture = + create(queueId, ItemCreateParams.none()) + + /** @see create */ + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + ): CompletableFuture = create(queueId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create(params: ItemCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(queueId, ItemCreateParams.none(), requestOptions) + + /** + * Partially update membership fields (added_at, last_reviewed_time) for a single annotation + * queue item by membership id. Works for RUN and THREAD rows. Omit a field (or pass JSON null) + * to leave it unchanged. + */ + fun update(itemId: String, params: ItemUpdateParams): CompletableFuture = + update(itemId, params, RequestOptions.none()) + + /** @see update */ + fun update( + itemId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see update */ + fun update(params: ItemUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * List RUN and THREAD items in a single annotation queue for one review status section, with + * opaque cursor pagination. Optional item_type=RUN|THREAD filters the page. direction=backward + * returns items before the supplied cursor. Response is membership metadata only (no nested + * run/thread store payloads). status=archived returns items in annotation_queue_runs_archive + * (queue completion rule met), not merely items the caller personally marked completed. + */ + fun list(queueId: String, params: ItemListParams): CompletableFuture = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + fun list( + queueId: String, + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + fun list(params: ItemListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Log the caller's reviewer status for a RUN or THREAD annotation queue item. A null status + * re-shows the item for this reviewer. + */ + fun createStatus(queueItemId: String): CompletableFuture = + createStatus(queueItemId, ItemCreateStatusParams.none()) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createStatus(params.toBuilder().queueItemId(queueItemId).build(), requestOptions) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + ): CompletableFuture = + createStatus(queueItemId, params, RequestOptions.none()) + + /** @see createStatus */ + fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see createStatus */ + fun createStatus(params: ItemCreateStatusParams): CompletableFuture = + createStatus(params, RequestOptions.none()) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + createStatus(queueItemId, ItemCreateStatusParams.none(), requestOptions) + + /** Remove RUN or THREAD items from a single annotation queue by membership ID. */ + fun deleteAll(queueId: String): CompletableFuture = + deleteAll(queueId, ItemDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deleteAll(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + ): CompletableFuture = deleteAll(queueId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see deleteAll */ + fun deleteAll(params: ItemDeleteAllParams): CompletableFuture = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + deleteAll(queueId, ItemDeleteAllParams.none(), requestOptions) + + /** + * Returns the number of annotation queue items for the requested reviewer-specific or archived + * bucket. + */ + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + ): CompletableFuture = + retrieveCount(queueId, params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveCount(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveCount */ + fun retrieveCount( + params: ItemRetrieveCountParams + ): CompletableFuture = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Resolve a RUN or THREAD item to its current review section and zero-based position for deep + * linking. + */ + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + ): CompletableFuture = + retrievePlacement(itemId, params, RequestOptions.none()) + + /** @see retrievePlacement */ + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrievePlacement(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see retrievePlacement */ + fun retrievePlacement( + params: ItemRetrievePlacementParams + ): CompletableFuture = + retrievePlacement(params, RequestOptions.none()) + + /** @see retrievePlacement */ + fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [ItemServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/items`, but is + * otherwise the same as [ItemServiceAsync.create]. + */ + fun create(queueId: String): CompletableFuture> = + create(queueId, ItemCreateParams.none()) + + /** @see create */ + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + ): CompletableFuture> = + create(queueId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: ItemCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(queueId, ItemCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch + * /api/v1/annotation-queues/{queue_id}/items/{item_id}`, but is otherwise the same as + * [ItemServiceAsync.update]. + */ + fun update( + itemId: String, + params: ItemUpdateParams, + ): CompletableFuture> = + update(itemId, params, RequestOptions.none()) + + /** @see update */ + fun update( + itemId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see update */ + fun update( + params: ItemUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/items`, but is + * otherwise the same as [ItemServiceAsync.list]. + */ + fun list( + queueId: String, + params: ItemListParams, + ): CompletableFuture> = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + fun list( + queueId: String, + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + fun list(params: ItemListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /api/v1/annotation-queues/items/{queue_item_id}/status`, but is otherwise the same as + * [ItemServiceAsync.createStatus]. + */ + fun createStatus( + queueItemId: String + ): CompletableFuture> = + createStatus(queueItemId, ItemCreateStatusParams.none()) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createStatus(params.toBuilder().queueItemId(queueItemId).build(), requestOptions) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + ): CompletableFuture> = + createStatus(queueItemId, params, RequestOptions.none()) + + /** @see createStatus */ + fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see createStatus */ + fun createStatus( + params: ItemCreateStatusParams + ): CompletableFuture> = + createStatus(params, RequestOptions.none()) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + createStatus(queueItemId, ItemCreateStatusParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/items/delete`, + * but is otherwise the same as [ItemServiceAsync.deleteAll]. + */ + fun deleteAll(queueId: String): CompletableFuture> = + deleteAll(queueId, ItemDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + deleteAll(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + ): CompletableFuture> = + deleteAll(queueId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see deleteAll */ + fun deleteAll( + params: ItemDeleteAllParams + ): CompletableFuture> = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + deleteAll(queueId, ItemDeleteAllParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/items/count`, + * but is otherwise the same as [ItemServiceAsync.retrieveCount]. + */ + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + ): CompletableFuture> = + retrieveCount(queueId, params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveCount(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveCount */ + fun retrieveCount( + params: ItemRetrieveCountParams + ): CompletableFuture> = + retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get + * /api/v1/annotation-queues/{queue_id}/items/{item_id}/placement`, but is otherwise the + * same as [ItemServiceAsync.retrievePlacement]. + */ + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + ): CompletableFuture> = + retrievePlacement(itemId, params, RequestOptions.none()) + + /** @see retrievePlacement */ + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrievePlacement(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see retrievePlacement */ + fun retrievePlacement( + params: ItemRetrievePlacementParams + ): CompletableFuture> = + retrievePlacement(params, RequestOptions.none()) + + /** @see retrievePlacement */ + fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsyncImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsyncImpl.kt new file mode 100644 index 00000000..1a53de74 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsyncImpl.kt @@ -0,0 +1,403 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.async.annotationqueues + +import com.langchain.smith.core.ClientOptions +import com.langchain.smith.core.RequestOptions +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.handlers.errorBodyHandler +import com.langchain.smith.core.handlers.errorHandler +import com.langchain.smith.core.handlers.jsonHandler +import com.langchain.smith.core.http.HttpMethod +import com.langchain.smith.core.http.HttpRequest +import com.langchain.smith.core.http.HttpResponse +import com.langchain.smith.core.http.HttpResponse.Handler +import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.core.http.json +import com.langchain.smith.core.http.parseable +import com.langchain.smith.core.prepareAsync +import com.langchain.smith.models.annotationqueues.items.ItemCreateParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateResponse +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusResponse +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllParams +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllResponse +import com.langchain.smith.models.annotationqueues.items.ItemListPageAsync +import com.langchain.smith.models.annotationqueues.items.ItemListPageResponse +import com.langchain.smith.models.annotationqueues.items.ItemListParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountResponse +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementResponse +import com.langchain.smith.models.annotationqueues.items.ItemUpdateParams +import com.langchain.smith.models.annotationqueues.items.ItemUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ItemServiceAsync { + + private val withRawResponse: ItemServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ItemServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ItemServiceAsync = + ItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ItemCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/annotation-queues/{queue_id}/items + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /api/v1/annotation-queues/{queue_id}/items/{item_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ItemListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/annotation-queues/{queue_id}/items + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/annotation-queues/items/{queue_item_id}/status + withRawResponse().createStatus(params, requestOptions).thenApply { it.parse() } + + override fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/annotation-queues/{queue_id}/items/delete + withRawResponse().deleteAll(params, requestOptions).thenApply { it.parse() } + + override fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/annotation-queues/{queue_id}/items/count + withRawResponse().retrieveCount(params, requestOptions).thenApply { it.parse() } + + override fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/annotation-queues/{queue_id}/items/{item_id}/placement + withRawResponse().retrievePlacement(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ItemServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ItemServiceAsync.WithRawResponse = + ItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ItemCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + ) + .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 { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + params._pathParam(1), + ) + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: ItemListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ItemListPageAsync.builder() + .service(ItemServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val createStatusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueItemId", params.queueItemId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + "items", + params._pathParam(0), + "status", + ) + .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 { createStatusHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteAllHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + "delete", + ) + .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 { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveCountHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + "count", + ) + .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 { retrieveCountHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrievePlacementHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + params._pathParam(1), + "placement", + ) + .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 { retrievePlacementHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueService.kt index e4a272af..40946b0f 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueService.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueService.kt @@ -29,6 +29,7 @@ import com.langchain.smith.models.annotationqueues.AnnotationQueueSizeSchema import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateParams import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateResponse import com.langchain.smith.models.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langchain.smith.services.blocking.annotationqueues.ItemService import com.langchain.smith.services.blocking.annotationqueues.RunService import java.util.function.Consumer @@ -48,6 +49,8 @@ interface AnnotationQueueService { fun runs(): RunService + fun items(): ItemService + /** Get Annotation Queue */ fun retrieve(queueId: String): AnnotationQueueRetrieveResponse = retrieve(queueId, AnnotationQueueRetrieveParams.none()) @@ -452,6 +455,8 @@ interface AnnotationQueueService { fun runs(): RunService.WithRawResponse + fun items(): ItemService.WithRawResponse + /** * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}`, but is * otherwise the same as [AnnotationQueueService.retrieve]. diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceImpl.kt index 0fa7ab7e..7383807d 100644 --- a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceImpl.kt +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/AnnotationQueueServiceImpl.kt @@ -40,6 +40,8 @@ import com.langchain.smith.models.annotationqueues.AnnotationQueueSizeSchema import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateParams import com.langchain.smith.models.annotationqueues.AnnotationQueueUpdateResponse import com.langchain.smith.models.annotationqueues.RunSchemaWithAnnotationQueueInfo +import com.langchain.smith.services.blocking.annotationqueues.ItemService +import com.langchain.smith.services.blocking.annotationqueues.ItemServiceImpl import com.langchain.smith.services.blocking.annotationqueues.RunService import com.langchain.smith.services.blocking.annotationqueues.RunServiceImpl import java.util.function.Consumer @@ -54,6 +56,8 @@ class AnnotationQueueServiceImpl internal constructor(private val clientOptions: private val runs: RunService by lazy { RunServiceImpl(clientOptions) } + private val items: ItemService by lazy { ItemServiceImpl(clientOptions) } + override fun withRawResponse(): AnnotationQueueService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): AnnotationQueueService = @@ -61,6 +65,8 @@ class AnnotationQueueServiceImpl internal constructor(private val clientOptions: override fun runs(): RunService = runs + override fun items(): ItemService = items + override fun retrieve( params: AnnotationQueueRetrieveParams, requestOptions: RequestOptions, @@ -162,6 +168,10 @@ class AnnotationQueueServiceImpl internal constructor(private val clientOptions: RunServiceImpl.WithRawResponseImpl(clientOptions) } + private val items: ItemService.WithRawResponse by lazy { + ItemServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): AnnotationQueueService.WithRawResponse = @@ -171,6 +181,8 @@ class AnnotationQueueServiceImpl internal constructor(private val clientOptions: override fun runs(): RunService.WithRawResponse = runs + override fun items(): ItemService.WithRawResponse = items + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemService.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemService.kt new file mode 100644 index 00000000..f4bfc955 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemService.kt @@ -0,0 +1,517 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.blocking.annotationqueues + +import com.google.errorprone.annotations.MustBeClosed +import com.langchain.smith.core.ClientOptions +import com.langchain.smith.core.RequestOptions +import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.models.annotationqueues.items.ItemCreateParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateResponse +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusResponse +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllParams +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllResponse +import com.langchain.smith.models.annotationqueues.items.ItemListPage +import com.langchain.smith.models.annotationqueues.items.ItemListParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountResponse +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementResponse +import com.langchain.smith.models.annotationqueues.items.ItemUpdateParams +import com.langchain.smith.models.annotationqueues.items.ItemUpdateResponse +import java.util.function.Consumer + +interface ItemService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemService + + /** + * Add RUN or THREAD items to a single annotation queue. THREAD items require thread_id and + * session_id; RUN items require run_id, or source_proposed_example_id with lookup coordinates + * when applicable. + */ + fun create(queueId: String): ItemCreateResponse = create(queueId, ItemCreateParams.none()) + + /** @see create */ + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemCreateResponse = create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + ): ItemCreateResponse = create(queueId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemCreateResponse + + /** @see create */ + fun create(params: ItemCreateParams): ItemCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create(queueId: String, requestOptions: RequestOptions): ItemCreateResponse = + create(queueId, ItemCreateParams.none(), requestOptions) + + /** + * Partially update membership fields (added_at, last_reviewed_time) for a single annotation + * queue item by membership id. Works for RUN and THREAD rows. Omit a field (or pass JSON null) + * to leave it unchanged. + */ + fun update(itemId: String, params: ItemUpdateParams): ItemUpdateResponse = + update(itemId, params, RequestOptions.none()) + + /** @see update */ + fun update( + itemId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemUpdateResponse = update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see update */ + fun update(params: ItemUpdateParams): ItemUpdateResponse = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemUpdateResponse + + /** + * List RUN and THREAD items in a single annotation queue for one review status section, with + * opaque cursor pagination. Optional item_type=RUN|THREAD filters the page. direction=backward + * returns items before the supplied cursor. Response is membership metadata only (no nested + * run/thread store payloads). status=archived returns items in annotation_queue_runs_archive + * (queue completion rule met), not merely items the caller personally marked completed. + */ + fun list(queueId: String, params: ItemListParams): ItemListPage = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + fun list( + queueId: String, + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemListPage = list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + fun list(params: ItemListParams): ItemListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemListPage + + /** + * Log the caller's reviewer status for a RUN or THREAD annotation queue item. A null status + * re-shows the item for this reviewer. + */ + fun createStatus(queueItemId: String): ItemCreateStatusResponse = + createStatus(queueItemId, ItemCreateStatusParams.none()) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemCreateStatusResponse = + createStatus(params.toBuilder().queueItemId(queueItemId).build(), requestOptions) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + ): ItemCreateStatusResponse = createStatus(queueItemId, params, RequestOptions.none()) + + /** @see createStatus */ + fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemCreateStatusResponse + + /** @see createStatus */ + fun createStatus(params: ItemCreateStatusParams): ItemCreateStatusResponse = + createStatus(params, RequestOptions.none()) + + /** @see createStatus */ + fun createStatus( + queueItemId: String, + requestOptions: RequestOptions, + ): ItemCreateStatusResponse = + createStatus(queueItemId, ItemCreateStatusParams.none(), requestOptions) + + /** Remove RUN or THREAD items from a single annotation queue by membership ID. */ + fun deleteAll(queueId: String): ItemDeleteAllResponse = + deleteAll(queueId, ItemDeleteAllParams.none()) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemDeleteAllResponse = + deleteAll(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see deleteAll */ + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + ): ItemDeleteAllResponse = deleteAll(queueId, params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemDeleteAllResponse + + /** @see deleteAll */ + fun deleteAll(params: ItemDeleteAllParams): ItemDeleteAllResponse = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + fun deleteAll(queueId: String, requestOptions: RequestOptions): ItemDeleteAllResponse = + deleteAll(queueId, ItemDeleteAllParams.none(), requestOptions) + + /** + * Returns the number of annotation queue items for the requested reviewer-specific or archived + * bucket. + */ + fun retrieveCount(queueId: String, params: ItemRetrieveCountParams): ItemRetrieveCountResponse = + retrieveCount(queueId, params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemRetrieveCountResponse = + retrieveCount(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveCount */ + fun retrieveCount(params: ItemRetrieveCountParams): ItemRetrieveCountResponse = + retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemRetrieveCountResponse + + /** + * Resolve a RUN or THREAD item to its current review section and zero-based position for deep + * linking. + */ + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + ): ItemRetrievePlacementResponse = retrievePlacement(itemId, params, RequestOptions.none()) + + /** @see retrievePlacement */ + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemRetrievePlacementResponse = + retrievePlacement(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see retrievePlacement */ + fun retrievePlacement(params: ItemRetrievePlacementParams): ItemRetrievePlacementResponse = + retrievePlacement(params, RequestOptions.none()) + + /** @see retrievePlacement */ + fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ItemRetrievePlacementResponse + + /** A view of [ItemService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/items`, but is + * otherwise the same as [ItemService.create]. + */ + @MustBeClosed + fun create(queueId: String): HttpResponseFor = + create(queueId, ItemCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + queueId: String, + params: ItemCreateParams = ItemCreateParams.none(), + ): HttpResponseFor = create(queueId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ItemCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create(params: ItemCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(queueId, ItemCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch + * /api/v1/annotation-queues/{queue_id}/items/{item_id}`, but is otherwise the same as + * [ItemService.update]. + */ + @MustBeClosed + fun update(itemId: String, params: ItemUpdateParams): HttpResponseFor = + update(itemId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + itemId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ItemUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/items`, but is + * otherwise the same as [ItemService.list]. + */ + @MustBeClosed + fun list(queueId: String, params: ItemListParams): HttpResponseFor = + list(queueId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + queueId: String, + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list(params: ItemListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ItemListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /api/v1/annotation-queues/items/{queue_item_id}/status`, but is otherwise the same as + * [ItemService.createStatus]. + */ + @MustBeClosed + fun createStatus(queueItemId: String): HttpResponseFor = + createStatus(queueItemId, ItemCreateStatusParams.none()) + + /** @see createStatus */ + @MustBeClosed + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createStatus(params.toBuilder().queueItemId(queueItemId).build(), requestOptions) + + /** @see createStatus */ + @MustBeClosed + fun createStatus( + queueItemId: String, + params: ItemCreateStatusParams = ItemCreateStatusParams.none(), + ): HttpResponseFor = + createStatus(queueItemId, params, RequestOptions.none()) + + /** @see createStatus */ + @MustBeClosed + fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see createStatus */ + @MustBeClosed + fun createStatus( + params: ItemCreateStatusParams + ): HttpResponseFor = createStatus(params, RequestOptions.none()) + + /** @see createStatus */ + @MustBeClosed + fun createStatus( + queueItemId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + createStatus(queueItemId, ItemCreateStatusParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/annotation-queues/{queue_id}/items/delete`, + * but is otherwise the same as [ItemService.deleteAll]. + */ + @MustBeClosed + fun deleteAll(queueId: String): HttpResponseFor = + deleteAll(queueId, ItemDeleteAllParams.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deleteAll(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + queueId: String, + params: ItemDeleteAllParams = ItemDeleteAllParams.none(), + ): HttpResponseFor = + deleteAll(queueId, params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll(params: ItemDeleteAllParams): HttpResponseFor = + deleteAll(params, RequestOptions.none()) + + /** @see deleteAll */ + @MustBeClosed + fun deleteAll( + queueId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deleteAll(queueId, ItemDeleteAllParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/annotation-queues/{queue_id}/items/count`, + * but is otherwise the same as [ItemService.retrieveCount]. + */ + @MustBeClosed + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + ): HttpResponseFor = + retrieveCount(queueId, params, RequestOptions.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + queueId: String, + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveCount(params.toBuilder().queueId(queueId).build(), requestOptions) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + params: ItemRetrieveCountParams + ): HttpResponseFor = retrieveCount(params, RequestOptions.none()) + + /** @see retrieveCount */ + @MustBeClosed + fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get + * /api/v1/annotation-queues/{queue_id}/items/{item_id}/placement`, but is otherwise the + * same as [ItemService.retrievePlacement]. + */ + @MustBeClosed + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + ): HttpResponseFor = + retrievePlacement(itemId, params, RequestOptions.none()) + + /** @see retrievePlacement */ + @MustBeClosed + fun retrievePlacement( + itemId: String, + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrievePlacement(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see retrievePlacement */ + @MustBeClosed + fun retrievePlacement( + params: ItemRetrievePlacementParams + ): HttpResponseFor = + retrievePlacement(params, RequestOptions.none()) + + /** @see retrievePlacement */ + @MustBeClosed + fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemServiceImpl.kt b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemServiceImpl.kt new file mode 100644 index 00000000..500b33e1 --- /dev/null +++ b/langsmith-java-core/src/main/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemServiceImpl.kt @@ -0,0 +1,376 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.blocking.annotationqueues + +import com.langchain.smith.core.ClientOptions +import com.langchain.smith.core.RequestOptions +import com.langchain.smith.core.checkRequired +import com.langchain.smith.core.handlers.errorBodyHandler +import com.langchain.smith.core.handlers.errorHandler +import com.langchain.smith.core.handlers.jsonHandler +import com.langchain.smith.core.http.HttpMethod +import com.langchain.smith.core.http.HttpRequest +import com.langchain.smith.core.http.HttpResponse +import com.langchain.smith.core.http.HttpResponse.Handler +import com.langchain.smith.core.http.HttpResponseFor +import com.langchain.smith.core.http.json +import com.langchain.smith.core.http.parseable +import com.langchain.smith.core.prepare +import com.langchain.smith.models.annotationqueues.items.ItemCreateParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateResponse +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusResponse +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllParams +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllResponse +import com.langchain.smith.models.annotationqueues.items.ItemListPage +import com.langchain.smith.models.annotationqueues.items.ItemListPageResponse +import com.langchain.smith.models.annotationqueues.items.ItemListParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountResponse +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementResponse +import com.langchain.smith.models.annotationqueues.items.ItemUpdateParams +import com.langchain.smith.models.annotationqueues.items.ItemUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { + + private val withRawResponse: ItemService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ItemService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ItemService = + ItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ItemCreateParams, + requestOptions: RequestOptions, + ): ItemCreateResponse = + // post /api/v1/annotation-queues/{queue_id}/items + withRawResponse().create(params, requestOptions).parse() + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): ItemUpdateResponse = + // patch /api/v1/annotation-queues/{queue_id}/items/{item_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ItemListParams, requestOptions: RequestOptions): ItemListPage = + // get /api/v1/annotation-queues/{queue_id}/items + withRawResponse().list(params, requestOptions).parse() + + override fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions, + ): ItemCreateStatusResponse = + // post /api/v1/annotation-queues/items/{queue_item_id}/status + withRawResponse().createStatus(params, requestOptions).parse() + + override fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions, + ): ItemDeleteAllResponse = + // post /api/v1/annotation-queues/{queue_id}/items/delete + withRawResponse().deleteAll(params, requestOptions).parse() + + override fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions, + ): ItemRetrieveCountResponse = + // get /api/v1/annotation-queues/{queue_id}/items/count + withRawResponse().retrieveCount(params, requestOptions).parse() + + override fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions, + ): ItemRetrievePlacementResponse = + // get /api/v1/annotation-queues/{queue_id}/items/{item_id}/placement + withRawResponse().retrievePlacement(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ItemService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ItemService.WithRawResponse = + ItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ItemCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + ) + .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 { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + params._pathParam(1), + ) + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: ItemListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + ItemListPage.builder() + .service(ItemServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val createStatusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createStatus( + params: ItemCreateStatusParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueItemId", params.queueItemId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + "items", + params._pathParam(0), + "status", + ) + .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 { createStatusHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteAllHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun deleteAll( + params: ItemDeleteAllParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + "delete", + ) + .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 { deleteAllHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveCountHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveCount( + params: ItemRetrieveCountParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("queueId", params.queueId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + "count", + ) + .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 { retrieveCountHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrievePlacementHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrievePlacement( + params: ItemRetrievePlacementParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "annotation-queues", + params._pathParam(0), + "items", + params._pathParam(1), + "placement", + ) + .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 { retrievePlacementHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateParamsTest.kt new file mode 100644 index 00000000..5595ae48 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateParamsTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.http.QueryParams +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemCreateParamsTest { + + @Test + fun create() { + ItemCreateParams.builder() + .queueId("queue_id") + .extendTraceRetention(true) + .addItem( + ItemCreateParams.Item.builder() + .itemType(ItemCreateParams.Item.ItemType.RUN) + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .threadId("thread_id") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = ItemCreateParams.builder().queueId("queue_id").build() + + assertThat(params._pathParam(0)).isEqualTo("queue_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ItemCreateParams.builder() + .queueId("queue_id") + .extendTraceRetention(true) + .addItem( + ItemCreateParams.Item.builder() + .itemType(ItemCreateParams.Item.ItemType.RUN) + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .threadId("thread_id") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("extend_trace_retention", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ItemCreateParams.builder().queueId("queue_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + ItemCreateParams.builder() + .queueId("queue_id") + .extendTraceRetention(true) + .addItem( + ItemCreateParams.Item.builder() + .itemType(ItemCreateParams.Item.ItemType.RUN) + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .threadId("thread_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.items().getOrNull()) + .containsExactly( + ItemCreateParams.Item.builder() + .itemType(ItemCreateParams.Item.ItemType.RUN) + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .threadId("thread_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ItemCreateParams.builder().queueId("queue_id").build() + + val body = params._body() + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateResponseTest.kt new file mode 100644 index 00000000..c229231f --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateResponseTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemCreateResponseTest { + + @Test + fun create() { + val itemCreateResponse = + ItemCreateResponse.builder() + .addItem( + ItemCreateResponse.Item.builder() + .id("id") + .addedAt("added_at") + .itemType(ItemCreateResponse.Item.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + ) + .build() + + assertThat(itemCreateResponse.items().getOrNull()) + .containsExactly( + ItemCreateResponse.Item.builder() + .id("id") + .addedAt("added_at") + .itemType(ItemCreateResponse.Item.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemCreateResponse = + ItemCreateResponse.builder() + .addItem( + ItemCreateResponse.Item.builder() + .id("id") + .addedAt("added_at") + .itemType(ItemCreateResponse.Item.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + ) + .build() + + val roundtrippedItemCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemCreateResponse).isEqualTo(itemCreateResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusParamsTest.kt new file mode 100644 index 00000000..216e0eee --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusParamsTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemCreateStatusParamsTest { + + @Test + fun create() { + ItemCreateStatusParams.builder() + .queueItemId("queue_item_id") + .overrideAddedAt("override_added_at") + .status(ItemCreateStatusParams.Status.VIEWED) + .build() + } + + @Test + fun pathParams() { + val params = ItemCreateStatusParams.builder().queueItemId("queue_item_id").build() + + assertThat(params._pathParam(0)).isEqualTo("queue_item_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ItemCreateStatusParams.builder() + .queueItemId("queue_item_id") + .overrideAddedAt("override_added_at") + .status(ItemCreateStatusParams.Status.VIEWED) + .build() + + val body = params._body() + + assertThat(body.overrideAddedAt()).contains("override_added_at") + assertThat(body.status()).contains(ItemCreateStatusParams.Status.VIEWED) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ItemCreateStatusParams.builder().queueItemId("queue_item_id").build() + + val body = params._body() + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusResponseTest.kt new file mode 100644 index 00000000..07f9d262 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemCreateStatusResponseTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemCreateStatusResponseTest { + + @Test + fun create() { + val itemCreateStatusResponse = + ItemCreateStatusResponse.builder() + .isArchived(true) + .overrideAddedAt("override_added_at") + .queueItemId("queue_item_id") + .status(ItemCreateStatusResponse.Status.VIEWED) + .build() + + assertThat(itemCreateStatusResponse.isArchived()).contains(true) + assertThat(itemCreateStatusResponse.overrideAddedAt()).contains("override_added_at") + assertThat(itemCreateStatusResponse.queueItemId()).contains("queue_item_id") + assertThat(itemCreateStatusResponse.status()) + .contains(ItemCreateStatusResponse.Status.VIEWED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemCreateStatusResponse = + ItemCreateStatusResponse.builder() + .isArchived(true) + .overrideAddedAt("override_added_at") + .queueItemId("queue_item_id") + .status(ItemCreateStatusResponse.Status.VIEWED) + .build() + + val roundtrippedItemCreateStatusResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemCreateStatusResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemCreateStatusResponse).isEqualTo(itemCreateStatusResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllParamsTest.kt new file mode 100644 index 00000000..e8966592 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllParamsTest.kt @@ -0,0 +1,40 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemDeleteAllParamsTest { + + @Test + fun create() { + ItemDeleteAllParams.builder().queueId("queue_id").addItemId("string").build() + } + + @Test + fun pathParams() { + val params = ItemDeleteAllParams.builder().queueId("queue_id").build() + + assertThat(params._pathParam(0)).isEqualTo("queue_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = ItemDeleteAllParams.builder().queueId("queue_id").addItemId("string").build() + + val body = params._body() + + assertThat(body.itemIds().getOrNull()).containsExactly("string") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ItemDeleteAllParams.builder().queueId("queue_id").build() + + val body = params._body() + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllResponseTest.kt new file mode 100644 index 00000000..fff6f018 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemDeleteAllResponseTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.JsonValue +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemDeleteAllResponseTest { + + @Test + fun create() { + val itemDeleteAllResponse = + ItemDeleteAllResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemDeleteAllResponse = + ItemDeleteAllResponse.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + + val roundtrippedItemDeleteAllResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemDeleteAllResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemDeleteAllResponse).isEqualTo(itemDeleteAllResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageResponseTest.kt new file mode 100644 index 00000000..8e00dd16 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListPageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemListPageResponseTest { + + @Test + fun create() { + val itemListPageResponse = + ItemListPageResponse.builder() + .addItem( + ItemListResponse.builder() + .id("id") + .addedAt("added_at") + .addCompletedBy("string") + .effectiveAddedAt("effective_added_at") + .itemType(ItemListResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .addReservedBy("string") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + ) + .nextCursor("next_cursor") + .previousCursor("previous_cursor") + .build() + + assertThat(itemListPageResponse.items().getOrNull()) + .containsExactly( + ItemListResponse.builder() + .id("id") + .addedAt("added_at") + .addCompletedBy("string") + .effectiveAddedAt("effective_added_at") + .itemType(ItemListResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .addReservedBy("string") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + ) + assertThat(itemListPageResponse.nextCursor()).contains("next_cursor") + assertThat(itemListPageResponse.previousCursor()).contains("previous_cursor") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemListPageResponse = + ItemListPageResponse.builder() + .addItem( + ItemListResponse.builder() + .id("id") + .addedAt("added_at") + .addCompletedBy("string") + .effectiveAddedAt("effective_added_at") + .itemType(ItemListResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .addReservedBy("string") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + ) + .nextCursor("next_cursor") + .previousCursor("previous_cursor") + .build() + + val roundtrippedItemListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemListPageResponse).isEqualTo(itemListPageResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListParamsTest.kt new file mode 100644 index 00000000..4ebbf3d0 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListParamsTest.kt @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemListParamsTest { + + @Test + fun create() { + ItemListParams.builder() + .queueId("queue_id") + .status(ItemListParams.Status.NEEDS_MY_REVIEW) + .cursor("cursor") + .direction(ItemListParams.Direction.FORWARD) + .itemType(ItemListParams.ItemType.RUN) + .pageSize(0L) + .build() + } + + @Test + fun pathParams() { + val params = + ItemListParams.builder() + .queueId("queue_id") + .status(ItemListParams.Status.NEEDS_MY_REVIEW) + .build() + + assertThat(params._pathParam(0)).isEqualTo("queue_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ItemListParams.builder() + .queueId("queue_id") + .status(ItemListParams.Status.NEEDS_MY_REVIEW) + .cursor("cursor") + .direction(ItemListParams.Direction.FORWARD) + .itemType(ItemListParams.ItemType.RUN) + .pageSize(0L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("status", "needs_my_review") + .put("cursor", "cursor") + .put("direction", "forward") + .put("item_type", "RUN") + .put("page_size", "0") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + ItemListParams.builder() + .queueId("queue_id") + .status(ItemListParams.Status.NEEDS_MY_REVIEW) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("status", "needs_my_review").build()) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListResponseTest.kt new file mode 100644 index 00000000..5dea853b --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemListResponseTest.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemListResponseTest { + + @Test + fun create() { + val itemListResponse = + ItemListResponse.builder() + .id("id") + .addedAt("added_at") + .addCompletedBy("string") + .effectiveAddedAt("effective_added_at") + .itemType(ItemListResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .addReservedBy("string") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + + assertThat(itemListResponse.id()).contains("id") + assertThat(itemListResponse.addedAt()).contains("added_at") + assertThat(itemListResponse.completedBy().getOrNull()).containsExactly("string") + assertThat(itemListResponse.effectiveAddedAt()).contains("effective_added_at") + assertThat(itemListResponse.itemType()).contains(ItemListResponse.ItemType.RUN) + assertThat(itemListResponse.lastReviewedTime()).contains("last_reviewed_time") + assertThat(itemListResponse.queueId()).contains("queue_id") + assertThat(itemListResponse.reservedBy().getOrNull()).containsExactly("string") + assertThat(itemListResponse.runId()).contains("run_id") + assertThat(itemListResponse.sessionId()).contains("session_id") + assertThat(itemListResponse.sourceProposedExampleId()) + .contains("source_proposed_example_id") + assertThat(itemListResponse.startTime()).contains("start_time") + assertThat(itemListResponse.threadId()).contains("thread_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemListResponse = + ItemListResponse.builder() + .id("id") + .addedAt("added_at") + .addCompletedBy("string") + .effectiveAddedAt("effective_added_at") + .itemType(ItemListResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .addReservedBy("string") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + + val roundtrippedItemListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemListResponse).isEqualTo(itemListResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountParamsTest.kt new file mode 100644 index 00000000..f495cd96 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.langchain.smith.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemRetrieveCountParamsTest { + + @Test + fun create() { + ItemRetrieveCountParams.builder() + .queueId("queue_id") + .status("status") + .endTime("end_time") + .startTime("start_time") + .build() + } + + @Test + fun pathParams() { + val params = ItemRetrieveCountParams.builder().queueId("queue_id").status("status").build() + + assertThat(params._pathParam(0)).isEqualTo("queue_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ItemRetrieveCountParams.builder() + .queueId("queue_id") + .status("status") + .endTime("end_time") + .startTime("start_time") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("status", "status") + .put("end_time", "end_time") + .put("start_time", "start_time") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ItemRetrieveCountParams.builder().queueId("queue_id").status("status").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("status", "status").build()) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountResponseTest.kt new file mode 100644 index 00000000..0eb7a469 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrieveCountResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemRetrieveCountResponseTest { + + @Test + fun create() { + val itemRetrieveCountResponse = ItemRetrieveCountResponse.builder().count(0L).build() + + assertThat(itemRetrieveCountResponse.count()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemRetrieveCountResponse = ItemRetrieveCountResponse.builder().count(0L).build() + + val roundtrippedItemRetrieveCountResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemRetrieveCountResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemRetrieveCountResponse).isEqualTo(itemRetrieveCountResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementParamsTest.kt new file mode 100644 index 00000000..af2f413f --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemRetrievePlacementParamsTest { + + @Test + fun create() { + ItemRetrievePlacementParams.builder().queueId("queue_id").itemId("item_id").build() + } + + @Test + fun pathParams() { + val params = + ItemRetrievePlacementParams.builder().queueId("queue_id").itemId("item_id").build() + + assertThat(params._pathParam(0)).isEqualTo("queue_id") + assertThat(params._pathParam(1)).isEqualTo("item_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementResponseTest.kt new file mode 100644 index 00000000..1dc357f3 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemRetrievePlacementResponseTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemRetrievePlacementResponseTest { + + @Test + fun create() { + val itemRetrievePlacementResponse = + ItemRetrievePlacementResponse.builder() + .cursor("cursor") + .itemType(ItemRetrievePlacementResponse.ItemType.RUN) + .position(0L) + .section(ItemRetrievePlacementResponse.Section.NEEDS_MY_REVIEW) + .build() + + assertThat(itemRetrievePlacementResponse.cursor()).contains("cursor") + assertThat(itemRetrievePlacementResponse.itemType()) + .contains(ItemRetrievePlacementResponse.ItemType.RUN) + assertThat(itemRetrievePlacementResponse.position()).contains(0L) + assertThat(itemRetrievePlacementResponse.section()) + .contains(ItemRetrievePlacementResponse.Section.NEEDS_MY_REVIEW) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemRetrievePlacementResponse = + ItemRetrievePlacementResponse.builder() + .cursor("cursor") + .itemType(ItemRetrievePlacementResponse.ItemType.RUN) + .position(0L) + .section(ItemRetrievePlacementResponse.Section.NEEDS_MY_REVIEW) + .build() + + val roundtrippedItemRetrievePlacementResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemRetrievePlacementResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemRetrievePlacementResponse) + .isEqualTo(itemRetrievePlacementResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateParamsTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateParamsTest.kt new file mode 100644 index 00000000..e2e9a828 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemUpdateParamsTest { + + @Test + fun create() { + ItemUpdateParams.builder() + .queueId("queue_id") + .itemId("item_id") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun pathParams() { + val params = ItemUpdateParams.builder().queueId("queue_id").itemId("item_id").build() + + assertThat(params._pathParam(0)).isEqualTo("queue_id") + assertThat(params._pathParam(1)).isEqualTo("item_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + ItemUpdateParams.builder() + .queueId("queue_id") + .itemId("item_id") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.addedAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.lastReviewedTime()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ItemUpdateParams.builder().queueId("queue_id").itemId("item_id").build() + + val body = params._body() + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateResponseTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateResponseTest.kt new file mode 100644 index 00000000..6ff00ffe --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/models/annotationqueues/items/ItemUpdateResponseTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.models.annotationqueues.items + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.langchain.smith.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemUpdateResponseTest { + + @Test + fun create() { + val itemUpdateResponse = + ItemUpdateResponse.builder() + .id("id") + .addedAt("added_at") + .itemType(ItemUpdateResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + + assertThat(itemUpdateResponse.id()).contains("id") + assertThat(itemUpdateResponse.addedAt()).contains("added_at") + assertThat(itemUpdateResponse.itemType()).contains(ItemUpdateResponse.ItemType.RUN) + assertThat(itemUpdateResponse.lastReviewedTime()).contains("last_reviewed_time") + assertThat(itemUpdateResponse.queueId()).contains("queue_id") + assertThat(itemUpdateResponse.runId()).contains("run_id") + assertThat(itemUpdateResponse.sessionId()).contains("session_id") + assertThat(itemUpdateResponse.sourceProposedExampleId()) + .contains("source_proposed_example_id") + assertThat(itemUpdateResponse.startTime()).contains("start_time") + assertThat(itemUpdateResponse.threadId()).contains("thread_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val itemUpdateResponse = + ItemUpdateResponse.builder() + .id("id") + .addedAt("added_at") + .itemType(ItemUpdateResponse.ItemType.RUN) + .lastReviewedTime("last_reviewed_time") + .queueId("queue_id") + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime("start_time") + .threadId("thread_id") + .build() + + val roundtrippedItemUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(itemUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedItemUpdateResponse).isEqualTo(itemUpdateResponse) + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsyncTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsyncTest.kt new file mode 100644 index 00000000..ecd60434 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/async/annotationqueues/ItemServiceAsyncTest.kt @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.async.annotationqueues + +import com.langchain.smith.client.okhttp.LangsmithOkHttpClientAsync +import com.langchain.smith.models.annotationqueues.items.ItemCreateParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusParams +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllParams +import com.langchain.smith.models.annotationqueues.items.ItemListParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementParams +import com.langchain.smith.models.annotationqueues.items.ItemUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class ItemServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val itemFuture = + itemServiceAsync.create( + ItemCreateParams.builder() + .queueId("queue_id") + .extendTraceRetention(true) + .addItem( + ItemCreateParams.Item.builder() + .itemType(ItemCreateParams.Item.ItemType.RUN) + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .threadId("thread_id") + .build() + ) + .build() + ) + + val item = itemFuture.get() + item.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val itemFuture = + itemServiceAsync.update( + ItemUpdateParams.builder() + .queueId("queue_id") + .itemId("item_id") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val item = itemFuture.get() + item.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val pageFuture = + itemServiceAsync.list( + ItemListParams.builder() + .queueId("queue_id") + .status(ItemListParams.Status.NEEDS_MY_REVIEW) + .build() + ) + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun createStatus() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val responseFuture = + itemServiceAsync.createStatus( + ItemCreateStatusParams.builder() + .queueItemId("queue_item_id") + .overrideAddedAt("override_added_at") + .status(ItemCreateStatusParams.Status.VIEWED) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val responseFuture = + itemServiceAsync.deleteAll( + ItemDeleteAllParams.builder().queueId("queue_id").addItemId("string").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieveCount() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val responseFuture = + itemServiceAsync.retrieveCount( + ItemRetrieveCountParams.builder() + .queueId("queue_id") + .status("status") + .endTime("end_time") + .startTime("start_time") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrievePlacement() { + val client = + LangsmithOkHttpClientAsync.builder() + .apiKey("My API Key") + .tenantId("My Tenant ID") + .build() + val itemServiceAsync = client.annotationQueues().items() + + val responseFuture = + itemServiceAsync.retrievePlacement( + ItemRetrievePlacementParams.builder().queueId("queue_id").itemId("item_id").build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemServiceTest.kt b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemServiceTest.kt new file mode 100644 index 00000000..29f69722 --- /dev/null +++ b/langsmith-java-core/src/test/kotlin/com/langchain/smith/services/blocking/annotationqueues/ItemServiceTest.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.langchain.smith.services.blocking.annotationqueues + +import com.langchain.smith.client.okhttp.LangsmithOkHttpClient +import com.langchain.smith.models.annotationqueues.items.ItemCreateParams +import com.langchain.smith.models.annotationqueues.items.ItemCreateStatusParams +import com.langchain.smith.models.annotationqueues.items.ItemDeleteAllParams +import com.langchain.smith.models.annotationqueues.items.ItemListParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrieveCountParams +import com.langchain.smith.models.annotationqueues.items.ItemRetrievePlacementParams +import com.langchain.smith.models.annotationqueues.items.ItemUpdateParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class ItemServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val item = + itemService.create( + ItemCreateParams.builder() + .queueId("queue_id") + .extendTraceRetention(true) + .addItem( + ItemCreateParams.Item.builder() + .itemType(ItemCreateParams.Item.ItemType.RUN) + .runId("run_id") + .sessionId("session_id") + .sourceProposedExampleId("source_proposed_example_id") + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .threadId("thread_id") + .build() + ) + .build() + ) + + item.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val item = + itemService.update( + ItemUpdateParams.builder() + .queueId("queue_id") + .itemId("item_id") + .addedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .lastReviewedTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + item.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val page = + itemService.list( + ItemListParams.builder() + .queueId("queue_id") + .status(ItemListParams.Status.NEEDS_MY_REVIEW) + .build() + ) + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun createStatus() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val response = + itemService.createStatus( + ItemCreateStatusParams.builder() + .queueItemId("queue_item_id") + .overrideAddedAt("override_added_at") + .status(ItemCreateStatusParams.Status.VIEWED) + .build() + ) + + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun deleteAll() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val response = + itemService.deleteAll( + ItemDeleteAllParams.builder().queueId("queue_id").addItemId("string").build() + ) + + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieveCount() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val response = + itemService.retrieveCount( + ItemRetrieveCountParams.builder() + .queueId("queue_id") + .status("status") + .endTime("end_time") + .startTime("start_time") + .build() + ) + + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrievePlacement() { + val client = + LangsmithOkHttpClient.builder().apiKey("My API Key").tenantId("My Tenant ID").build() + val itemService = client.annotationQueues().items() + + val response = + itemService.retrievePlacement( + ItemRetrievePlacementParams.builder().queueId("queue_id").itemId("item_id").build() + ) + + response.validate() + } +}