22
33package com.langchain.smith.models.annotationqueues
44
5+ import com.fasterxml.jackson.annotation.JsonCreator
6+ import com.langchain.smith.core.Enum
7+ import com.langchain.smith.core.JsonField
58import com.langchain.smith.core.Params
69import com.langchain.smith.core.http.Headers
710import com.langchain.smith.core.http.QueryParams
11+ import com.langchain.smith.errors.LangChainInvalidDataException
812import java.util.Objects
913import java.util.Optional
1014import kotlin.jvm.optionals.getOrNull
@@ -13,12 +17,15 @@ import kotlin.jvm.optionals.getOrNull
1317class AnnotationQueueRetrieveSizeParams
1418private constructor (
1519 private val queueId: String? ,
20+ private val status: Status ? ,
1621 private val additionalHeaders: Headers ,
1722 private val additionalQueryParams: QueryParams ,
1823) : Params {
1924
2025 fun queueId (): Optional <String > = Optional .ofNullable(queueId)
2126
27+ fun status (): Optional <Status > = Optional .ofNullable(status)
28+
2229 /* * Additional headers to send with the request. */
2330 fun _additionalHeaders (): Headers = additionalHeaders
2431
@@ -42,13 +49,15 @@ private constructor(
4249 class Builder internal constructor() {
4350
4451 private var queueId: String? = null
52+ private var status: Status ? = null
4553 private var additionalHeaders: Headers .Builder = Headers .builder()
4654 private var additionalQueryParams: QueryParams .Builder = QueryParams .builder()
4755
4856 @JvmSynthetic
4957 internal fun from (annotationQueueRetrieveSizeParams : AnnotationQueueRetrieveSizeParams ) =
5058 apply {
5159 queueId = annotationQueueRetrieveSizeParams.queueId
60+ status = annotationQueueRetrieveSizeParams.status
5261 additionalHeaders = annotationQueueRetrieveSizeParams.additionalHeaders.toBuilder()
5362 additionalQueryParams =
5463 annotationQueueRetrieveSizeParams.additionalQueryParams.toBuilder()
@@ -59,6 +68,11 @@ private constructor(
5968 /* * Alias for calling [Builder.queueId] with `queueId.orElse(null)`. */
6069 fun queueId (queueId : Optional <String >) = queueId(queueId.getOrNull())
6170
71+ fun status (status : Status ? ) = apply { this .status = status }
72+
73+ /* * Alias for calling [Builder.status] with `status.orElse(null)`. */
74+ fun status (status : Optional <Status >) = status(status.getOrNull())
75+
6276 fun additionalHeaders (additionalHeaders : Headers ) = apply {
6377 this .additionalHeaders.clear()
6478 putAllAdditionalHeaders(additionalHeaders)
@@ -165,6 +179,7 @@ private constructor(
165179 fun build (): AnnotationQueueRetrieveSizeParams =
166180 AnnotationQueueRetrieveSizeParams (
167181 queueId,
182+ status,
168183 additionalHeaders.build(),
169184 additionalQueryParams.build(),
170185 )
@@ -178,7 +193,146 @@ private constructor(
178193
179194 override fun _headers (): Headers = additionalHeaders
180195
181- override fun _queryParams (): QueryParams = additionalQueryParams
196+ override fun _queryParams (): QueryParams =
197+ QueryParams .builder()
198+ .apply {
199+ status?.let { put(" status" , it.toString()) }
200+ putAll(additionalQueryParams)
201+ }
202+ .build()
203+
204+ class Status @JsonCreator private constructor(private val value : JsonField <String >) : Enum {
205+
206+ /* *
207+ * Returns this class instance's raw value.
208+ *
209+ * This is usually only useful if this instance was deserialized from data that doesn't
210+ * match any known member, and you want to know that value. For example, if the SDK is on an
211+ * older version than the API, then the API may respond with new members that the SDK is
212+ * unaware of.
213+ */
214+ @com.fasterxml.jackson.annotation.JsonValue fun _value (): JsonField <String > = value
215+
216+ companion object {
217+
218+ @JvmField val NEEDS_MY_REVIEW = of(" needs_my_review" )
219+
220+ @JvmField val NEEDS_OTHERS_REVIEW = of(" needs_others_review" )
221+
222+ @JvmField val COMPLETED = of(" completed" )
223+
224+ @JvmStatic fun of (value : String ) = Status (JsonField .of(value))
225+ }
226+
227+ /* * An enum containing [Status]'s known values. */
228+ enum class Known {
229+ NEEDS_MY_REVIEW ,
230+ NEEDS_OTHERS_REVIEW ,
231+ COMPLETED ,
232+ }
233+
234+ /* *
235+ * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member.
236+ *
237+ * An instance of [Status] can contain an unknown value in a couple of cases:
238+ * - It was deserialized from data that doesn't match any known member. For example, if the
239+ * SDK is on an older version than the API, then the API may respond with new members that
240+ * the SDK is unaware of.
241+ * - It was constructed with an arbitrary value using the [of] method.
242+ */
243+ enum class Value {
244+ NEEDS_MY_REVIEW ,
245+ NEEDS_OTHERS_REVIEW ,
246+ COMPLETED ,
247+ /* * An enum member indicating that [Status] was instantiated with an unknown value. */
248+ _UNKNOWN ,
249+ }
250+
251+ /* *
252+ * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
253+ * if the class was instantiated with an unknown value.
254+ *
255+ * Use the [known] method instead if you're certain the value is always known or if you want
256+ * to throw for the unknown case.
257+ */
258+ fun value (): Value =
259+ when (this ) {
260+ NEEDS_MY_REVIEW -> Value .NEEDS_MY_REVIEW
261+ NEEDS_OTHERS_REVIEW -> Value .NEEDS_OTHERS_REVIEW
262+ COMPLETED -> Value .COMPLETED
263+ else -> Value ._UNKNOWN
264+ }
265+
266+ /* *
267+ * Returns an enum member corresponding to this class instance's value.
268+ *
269+ * Use the [value] method instead if you're uncertain the value is always known and don't
270+ * want to throw for the unknown case.
271+ *
272+ * @throws LangChainInvalidDataException if this class instance's value is a not a known
273+ * member.
274+ */
275+ fun known (): Known =
276+ when (this ) {
277+ NEEDS_MY_REVIEW -> Known .NEEDS_MY_REVIEW
278+ NEEDS_OTHERS_REVIEW -> Known .NEEDS_OTHERS_REVIEW
279+ COMPLETED -> Known .COMPLETED
280+ else -> throw LangChainInvalidDataException (" Unknown Status: $value " )
281+ }
282+
283+ /* *
284+ * Returns this class instance's primitive wire representation.
285+ *
286+ * This differs from the [toString] method because that method is primarily for debugging
287+ * and generally doesn't throw.
288+ *
289+ * @throws LangChainInvalidDataException if this class instance's value does not have the
290+ * expected primitive type.
291+ */
292+ fun asString (): String =
293+ _value ().asString().orElseThrow {
294+ LangChainInvalidDataException (" Value is not a String" )
295+ }
296+
297+ private var validated: Boolean = false
298+
299+ fun validate (): Status = apply {
300+ if (validated) {
301+ return @apply
302+ }
303+
304+ known()
305+ validated = true
306+ }
307+
308+ fun isValid (): Boolean =
309+ try {
310+ validate()
311+ true
312+ } catch (e: LangChainInvalidDataException ) {
313+ false
314+ }
315+
316+ /* *
317+ * Returns a score indicating how many valid values are contained in this object
318+ * recursively.
319+ *
320+ * Used for best match union deserialization.
321+ */
322+ @JvmSynthetic internal fun validity (): Int = if (value() == Value ._UNKNOWN ) 0 else 1
323+
324+ override fun equals (other : Any? ): Boolean {
325+ if (this == = other) {
326+ return true
327+ }
328+
329+ return other is Status && value == other.value
330+ }
331+
332+ override fun hashCode () = value.hashCode()
333+
334+ override fun toString () = value.toString()
335+ }
182336
183337 override fun equals (other : Any? ): Boolean {
184338 if (this == = other) {
@@ -187,12 +341,14 @@ private constructor(
187341
188342 return other is AnnotationQueueRetrieveSizeParams &&
189343 queueId == other.queueId &&
344+ status == other.status &&
190345 additionalHeaders == other.additionalHeaders &&
191346 additionalQueryParams == other.additionalQueryParams
192347 }
193348
194- override fun hashCode (): Int = Objects .hash(queueId, additionalHeaders, additionalQueryParams)
349+ override fun hashCode (): Int =
350+ Objects .hash(queueId, status, additionalHeaders, additionalQueryParams)
195351
196352 override fun toString () =
197- " AnnotationQueueRetrieveSizeParams{queueId=$queueId , additionalHeaders=$additionalHeaders , additionalQueryParams=$additionalQueryParams }"
353+ " AnnotationQueueRetrieveSizeParams{queueId=$queueId , status= $status , additionalHeaders=$additionalHeaders , additionalQueryParams=$additionalQueryParams }"
198354}
0 commit comments