diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt index 84e09911..e624381e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/BaseDeserializer.kt @@ -7,11 +7,9 @@ import com.fasterxml.jackson.databind.BeanProperty import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.JavaType import com.fasterxml.jackson.databind.JsonDeserializer -import com.fasterxml.jackson.databind.JsonMappingException import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.deser.ContextualDeserializer import com.fasterxml.jackson.databind.deser.std.StdDeserializer -import com.openlayer.api.errors.OpenlayerInvalidDataException import kotlin.reflect.KClass abstract class BaseDeserializer(type: KClass) : @@ -30,38 +28,17 @@ abstract class BaseDeserializer(type: KClass) : protected abstract fun ObjectCodec.deserialize(node: JsonNode): T - protected fun ObjectCodec.deserialize(node: JsonNode, type: TypeReference): T = + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = try { readValue(treeAsTokens(node), type) } catch (e: Exception) { - throw OpenlayerInvalidDataException("Error deserializing", e) - } - - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: TypeReference, - validate: (T) -> Unit = {}, - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { null } - } - protected fun ObjectCodec.tryDeserialize( - node: JsonNode, - type: JavaType, - validate: (T) -> Unit = {}, - ): T? { - return try { - readValue(treeAsTokens(node), type).apply(validate) - } catch (e: JsonMappingException) { - null - } catch (e: RuntimeException) { + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { null } - } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt index 396e33d3..4482ae3d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/Utils.kt @@ -25,6 +25,34 @@ internal fun , V> SortedMap.toImmutable(): SortedMap> Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + /** * Returns whether [this] is equal to [other]. * diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt index 31176c2d..99fb06d6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponse.kt @@ -805,7 +805,7 @@ private constructor( mlModelId() passingGoalCount() projectId() - status() + status().validate() statusMessage() storageUri() totalGoalCount() @@ -817,6 +817,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + /** The details of a commit (project version). */ class Commit private constructor( @@ -1416,6 +1449,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1549,6 +1611,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1680,6 +1769,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt index 19d68260..e46cfa17 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListParams.kt @@ -409,6 +409,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -531,6 +558,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt index c369a606..e7a82450 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponse.kt @@ -20,6 +20,7 @@ import com.openlayer.api.core.ExcludeMissing import com.openlayer.api.core.JsonField import com.openlayer.api.core.JsonMissing import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.allMaxBy import com.openlayer.api.core.checkKnown import com.openlayer.api.core.checkRequired import com.openlayer.api.core.getOrThrow @@ -164,6 +165,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Item private constructor( private val id: JsonField, @@ -722,13 +740,41 @@ private constructor( dateUpdated() inferencePipelineId() projectVersionId() - status() + status().validate() statusMessage() goal().ifPresent { it.validate() } goalId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateDataEnds.asKnown().isPresent) 1 else 0) + + (if (dateDataStarts.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineId.asKnown().isPresent) 1 else 0) + + (if (projectVersionId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (goal.asKnown().getOrNull()?.validity() ?: 0) + + (if (goalId.asKnown().isPresent) 1 else 0) + /** The status of the test. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -837,6 +883,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1888,6 +1961,44 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (commentCount.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (number.asKnown().isPresent) 1 else 0) + + (if (originProjectVersionId.asKnown().isPresent) 1 else 0) + + (if (subtype.asKnown().isPresent) 1 else 0) + + (if (suggested.asKnown().isPresent) 1 else 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (delayWindow.asKnown().isPresent) 1 else 0) + + (if (evaluationWindow.asKnown().isPresent) 1 else 0) + + (if (usesMlModel.asKnown().isPresent) 1 else 0) + + (if (usesProductionData.asKnown().isPresent) 1 else 0) + + (if (usesReferenceDataset.asKnown().isPresent) 1 else 0) + + (if (usesTrainingDataset.asKnown().isPresent) 1 else 0) + + (if (usesValidationDataset.asKnown().isPresent) 1 else 0) + class Threshold private constructor( private val insightName: JsonField, @@ -2195,6 +2306,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (insightName.asKnown().isPresent) 1 else 0) + + (insightParameters.asKnown().getOrNull()?.size ?: 0) + + (if (measurement.asKnown().isPresent) 1 else 0) + + (if (operator.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + /** The value to be compared. */ @JsonDeserialize(using = Value.Deserializer::class) @JsonSerialize(using = Value.Serializer::class) @@ -2233,15 +2366,14 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) string != null -> visitor.visitString(string) strings != null -> visitor.visitStrings(strings) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2264,6 +2396,36 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2329,20 +2491,36 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Value { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(bool = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Value(strings = it, _json = json) - } - - return Value(_json = json) } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt index 3110a204..b437b9f2 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveParams.kt @@ -308,6 +308,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Expand = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt index 05bbb2ae..80f97a34 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponse.kt @@ -843,7 +843,7 @@ private constructor( name() passingGoalCount() projectId() - status() + status().validate() statusMessage() totalGoalCount() project().ifPresent { it.validate() } @@ -852,6 +852,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + class Links private constructor( private val app: JsonField, @@ -970,6 +1004,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1099,6 +1149,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1842,8 +1919,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -1851,6 +1928,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -1974,6 +2084,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2087,6 +2213,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2203,6 +2356,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2747,6 +2927,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3539,7 +3748,7 @@ private constructor( periodStartDate() projectCount() slug() - status() + status().validate() inviteCode() monthlyUsage().ifPresent { it.forEach { it.validate() } } samlOnlyAccess() @@ -3547,6 +3756,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -3672,6 +3914,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3895,6 +4164,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt index af5a8c0b..3a9bc18e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateParams.kt @@ -522,6 +522,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (referenceDatasetUri.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt index 72473965..363ce7c4 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponse.kt @@ -843,7 +843,7 @@ private constructor( name() passingGoalCount() projectId() - status() + status().validate() statusMessage() totalGoalCount() project().ifPresent { it.validate() } @@ -852,6 +852,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + class Links private constructor( private val app: JsonField, @@ -970,6 +1004,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1099,6 +1149,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1842,8 +1919,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -1851,6 +1928,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -1974,6 +2084,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2087,6 +2213,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2203,6 +2356,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2747,6 +2927,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3539,7 +3748,7 @@ private constructor( periodStartDate() projectCount() slug() - status() + status().validate() inviteCode() monthlyUsage().ifPresent { it.forEach { it.validate() } } samlOnlyAccess() @@ -3547,6 +3756,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -3672,6 +3914,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3895,6 +4164,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt index 1eac98fa..0c636717 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamParams.kt @@ -20,6 +20,7 @@ import com.openlayer.api.core.JsonField import com.openlayer.api.core.JsonMissing import com.openlayer.api.core.JsonValue import com.openlayer.api.core.Params +import com.openlayer.api.core.allMaxBy import com.openlayer.api.core.checkKnown import com.openlayer.api.core.checkRequired import com.openlayer.api.core.getOrThrow @@ -520,6 +521,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (rows.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -582,8 +602,8 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { llmData != null -> visitor.visitLlmData(llmData) tabularClassificationData != null -> visitor.visitTabularClassificationData(tabularClassificationData) @@ -593,7 +613,6 @@ private constructor( visitor.visitTextClassificationData(textClassificationData) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -630,6 +649,42 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitLlmData(llmData: LlmData) = llmData.validity() + + override fun visitTabularClassificationData( + tabularClassificationData: TabularClassificationData + ) = tabularClassificationData.validity() + + override fun visitTabularRegressionData( + tabularRegressionData: TabularRegressionData + ) = tabularRegressionData.validity() + + override fun visitTextClassificationData( + textClassificationData: TextClassificationData + ) = textClassificationData.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -703,24 +758,34 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Config { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(llmData = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(tabularClassificationData = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(tabularRegressionData = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef()) { it.validate() } - ?.let { - return Config(textClassificationData = it, _json = json) - } - - return Config(_json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Config(llmData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Config(tabularClassificationData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Config(tabularRegressionData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Config(textClassificationData = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Config(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } } @@ -1371,6 +1436,34 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (outputColumnName.asKnown().isPresent) 1 else 0) + + (if (contextColumnName.asKnown().isPresent) 1 else 0) + + (if (costColumnName.asKnown().isPresent) 1 else 0) + + (if (groundTruthColumnName.asKnown().isPresent) 1 else 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (inputVariableNames.asKnown().getOrNull()?.size ?: 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (numOfTokenColumnName.asKnown().isPresent) 1 else 0) + + (prompt.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (questionColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + class Prompt private constructor( private val content: JsonField, @@ -1517,6 +1610,25 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (content.asKnown().isPresent) 1 else 0) + + (if (role.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2116,6 +2228,32 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (classNames.asKnown().getOrNull()?.size ?: 0) + + (categoricalFeatureNames.asKnown().getOrNull()?.size ?: 0) + + (featureNames.asKnown().getOrNull()?.size ?: 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (labelColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionsColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionScoresColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2572,6 +2710,30 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (categoricalFeatureNames.asKnown().getOrNull()?.size ?: 0) + + (featureNames.asKnown().getOrNull()?.size ?: 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionsColumnName.asKnown().isPresent) 1 else 0) + + (if (targetColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3078,6 +3240,31 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (classNames.asKnown().getOrNull()?.size ?: 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (labelColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionsColumnName.asKnown().isPresent) 1 else 0) + + (if (predictionScoresColumnName.asKnown().isPresent) 1 else 0) + + (if (textColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3163,6 +3350,24 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt index b66a3fd8..0c4e4c11 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponse.kt @@ -15,6 +15,7 @@ import com.openlayer.api.core.checkRequired import com.openlayer.api.errors.OpenlayerInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class DataStreamResponse private constructor( @@ -132,10 +133,25 @@ private constructor( return@apply } - success() + success().validate() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (success.asKnown().getOrNull()?.validity() ?: 0) + class Success @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -214,6 +230,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a Boolean") } + private var validated: Boolean = false + + fun validate(): Success = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt index 800f644c..720e088b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateParams.kt @@ -401,6 +401,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (config.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -755,6 +771,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (groundTruthColumnName.asKnown().isPresent) 1 else 0) + + (if (humanFeedbackColumnName.asKnown().isPresent) 1 else 0) + + (if (inferenceIdColumnName.asKnown().isPresent) 1 else 0) + + (if (latencyColumnName.asKnown().isPresent) 1 else 0) + + (if (timestampColumnName.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt index c1867d00..74ed1e2b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponse.kt @@ -15,6 +15,7 @@ import com.openlayer.api.core.checkRequired import com.openlayer.api.errors.OpenlayerInvalidDataException import java.util.Collections import java.util.Objects +import kotlin.jvm.optionals.getOrNull class RowUpdateResponse private constructor( @@ -132,10 +133,25 @@ private constructor( return@apply } - success() + success().validate() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (success.asKnown().getOrNull()?.validity() ?: 0) + class Success @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -214,6 +230,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a Boolean") } + private var validated: Boolean = false + + fun validate(): Success = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt index 4724a06f..b94b1557 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListParams.kt @@ -385,6 +385,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -507,6 +534,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt index e5b5efb6..48db95ef 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponse.kt @@ -20,6 +20,7 @@ import com.openlayer.api.core.ExcludeMissing import com.openlayer.api.core.JsonField import com.openlayer.api.core.JsonMissing import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.allMaxBy import com.openlayer.api.core.checkKnown import com.openlayer.api.core.checkRequired import com.openlayer.api.core.getOrThrow @@ -164,6 +165,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Item private constructor( private val id: JsonField, @@ -722,13 +740,41 @@ private constructor( dateUpdated() inferencePipelineId() projectVersionId() - status() + status().validate() statusMessage() goal().ifPresent { it.validate() } goalId() validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateDataEnds.asKnown().isPresent) 1 else 0) + + (if (dateDataStarts.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineId.asKnown().isPresent) 1 else 0) + + (if (projectVersionId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (goal.asKnown().getOrNull()?.validity() ?: 0) + + (if (goalId.asKnown().isPresent) 1 else 0) + /** The status of the test. */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -837,6 +883,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1888,6 +1961,44 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (commentCount.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (number.asKnown().isPresent) 1 else 0) + + (if (originProjectVersionId.asKnown().isPresent) 1 else 0) + + (if (subtype.asKnown().isPresent) 1 else 0) + + (if (suggested.asKnown().isPresent) 1 else 0) + + (thresholds.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (delayWindow.asKnown().isPresent) 1 else 0) + + (if (evaluationWindow.asKnown().isPresent) 1 else 0) + + (if (usesMlModel.asKnown().isPresent) 1 else 0) + + (if (usesProductionData.asKnown().isPresent) 1 else 0) + + (if (usesReferenceDataset.asKnown().isPresent) 1 else 0) + + (if (usesTrainingDataset.asKnown().isPresent) 1 else 0) + + (if (usesValidationDataset.asKnown().isPresent) 1 else 0) + class Threshold private constructor( private val insightName: JsonField, @@ -2195,6 +2306,28 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (insightName.asKnown().isPresent) 1 else 0) + + (insightParameters.asKnown().getOrNull()?.size ?: 0) + + (if (measurement.asKnown().isPresent) 1 else 0) + + (if (operator.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + /** The value to be compared. */ @JsonDeserialize(using = Value.Deserializer::class) @JsonSerialize(using = Value.Serializer::class) @@ -2233,15 +2366,14 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) - fun accept(visitor: Visitor): T { - return when { + fun accept(visitor: Visitor): T = + when { number != null -> visitor.visitNumber(number) bool != null -> visitor.visitBool(bool) string != null -> visitor.visitString(string) strings != null -> visitor.visitStrings(strings) else -> visitor.unknown(_json) } - } private var validated: Boolean = false @@ -2264,6 +2396,36 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitString(string: String) = 1 + + override fun visitStrings(strings: List) = strings.size + + override fun unknown(json: JsonValue?) = 0 + } + ) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2329,20 +2491,36 @@ private constructor( override fun ObjectCodec.deserialize(node: JsonNode): Value { val json = JsonValue.fromJsonNode(node) - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(number = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(bool = it, _json = json) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(strings = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() } - tryDeserialize(node, jacksonTypeRef())?.let { - return Value(string = it, _json = json) - } - tryDeserialize(node, jacksonTypeRef>())?.let { - return Value(strings = it, _json = json) - } - - return Value(_json = json) } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt index dd9e55ce..adf8f852 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateParams.kt @@ -1421,8 +1421,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -1430,6 +1430,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1567,6 +1600,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1678,6 +1727,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1791,6 +1867,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2312,6 +2415,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt index 31288f71..51d01c80 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectCreateResponse.kt @@ -726,8 +726,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -735,6 +735,38 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -854,6 +886,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -965,6 +1013,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1078,6 +1153,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1599,6 +1701,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt index 2bd38514..737094b5 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListParams.kt @@ -335,6 +335,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt index d38c17fb..f811e71a 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/ProjectListResponse.kt @@ -154,6 +154,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Item private constructor( private val id: JsonField, @@ -884,8 +901,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -893,6 +910,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -1016,6 +1066,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1129,6 +1195,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1245,6 +1338,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1789,6 +1909,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt index 41f05b20..9ca0dea6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateParams.kt @@ -1581,7 +1581,7 @@ private constructor( mlModelId() passingGoalCount() bodyProjectId() - status() + status().validate() statusMessage() storageUri() totalGoalCount() @@ -1593,6 +1593,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (bodyProjectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2210,6 +2244,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2343,6 +2406,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2474,6 +2564,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt index 3f5649f5..f28b09ce 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponse.kt @@ -805,7 +805,7 @@ private constructor( mlModelId() passingGoalCount() projectId() - status() + status().validate() statusMessage() storageUri() totalGoalCount() @@ -817,6 +817,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + /** The details of a commit (project version). */ class Commit private constructor( @@ -1416,6 +1449,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1549,6 +1611,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1680,6 +1769,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt index 92c586ab..ff18b25d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/commits/CommitListResponse.kt @@ -154,6 +154,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Item private constructor( private val id: JsonField, @@ -958,7 +975,7 @@ private constructor( mlModelId() passingGoalCount() projectId() - status() + status().validate() statusMessage() storageUri() totalGoalCount() @@ -970,6 +987,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (commit.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateArchived.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (archived.asKnown().isPresent) 1 else 0) + + (if (deploymentStatus.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + /** The details of a commit (project version). */ class Commit private constructor( @@ -1592,6 +1643,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (authorId.asKnown().isPresent) 1 else 0) + + (if (fileSize.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (mlModelId.asKnown().isPresent) 1 else 0) + + (if (storageUri.asKnown().isPresent) 1 else 0) + + (if (trainingDatasetId.asKnown().isPresent) 1 else 0) + + (if (validationDatasetId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (gitCommitRef.asKnown().isPresent) 1 else 0) + + (if (gitCommitSha.asKnown().isPresent) 1 else 0) + + (if (gitCommitUrl.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1727,6 +1807,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1862,6 +1969,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt index da3c7f1e..4340da74 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateParams.kt @@ -1639,7 +1639,7 @@ private constructor( name() passingGoalCount() bodyProjectId() - status() + status().validate() statusMessage() totalGoalCount() project().ifPresent { it.validate() } @@ -1648,6 +1648,41 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (bodyProjectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1784,6 +1819,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1913,6 +1964,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2656,8 +2734,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -2665,6 +2743,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -2788,6 +2899,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2901,6 +3028,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3017,6 +3171,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3561,6 +3742,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4353,7 +4563,7 @@ private constructor( periodStartDate() projectCount() slug() - status() + status().validate() inviteCode() monthlyUsage().ifPresent { it.forEach { it.validate() } } samlOnlyAccess() @@ -4361,6 +4571,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -4486,6 +4729,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4709,6 +4979,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt index 332de897..5df9ab5a 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponse.kt @@ -843,7 +843,7 @@ private constructor( name() passingGoalCount() projectId() - status() + status().validate() statusMessage() totalGoalCount() project().ifPresent { it.validate() } @@ -852,6 +852,40 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + class Links private constructor( private val app: JsonField, @@ -970,6 +1004,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1099,6 +1149,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1842,8 +1919,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -1851,6 +1928,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -1974,6 +2084,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2087,6 +2213,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2203,6 +2356,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2747,6 +2927,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3539,7 +3748,7 @@ private constructor( periodStartDate() projectCount() slug() - status() + status().validate() inviteCode() monthlyUsage().ifPresent { it.forEach { it.validate() } } samlOnlyAccess() @@ -3547,6 +3756,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -3672,6 +3914,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3895,6 +4164,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt index 829158de..33ca0476 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponse.kt @@ -156,6 +156,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Item private constructor( private val id: JsonField, @@ -996,7 +1013,7 @@ private constructor( name() passingGoalCount() projectId() - status() + status().validate() statusMessage() totalGoalCount() project().ifPresent { it.validate() } @@ -1005,6 +1022,41 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastEvaluated.asKnown().isPresent) 1 else 0) + + (if (dateLastSampleReceived.asKnown().isPresent) 1 else 0) + + (if (dateOfNextEvaluation.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (failingGoalCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (passingGoalCount.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusMessage.asKnown().isPresent) 1 else 0) + + (if (totalGoalCount.asKnown().isPresent) 1 else 0) + + (project.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + class Links private constructor( private val app: JsonField, @@ -1127,6 +1179,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1258,6 +1326,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2038,8 +2133,8 @@ private constructor( links().validate() monitoringGoalCount() name() - source() - taskType() + source().ifPresent { it.validate() } + taskType().validate() versionCount() workspaceId() description() @@ -2047,6 +2142,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (developmentGoalCount.asKnown().isPresent) 1 else 0) + + (if (goalCount.asKnown().isPresent) 1 else 0) + + (if (inferencePipelineCount.asKnown().isPresent) 1 else 0) + + (links.asKnown().getOrNull()?.validity() ?: 0) + + (if (monitoringGoalCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (taskType.asKnown().getOrNull()?.validity() ?: 0) + + (if (versionCount.asKnown().isPresent) 1 else 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (gitRepo.asKnown().getOrNull()?.validity() ?: 0) + /** Links to the project. */ class Links private constructor( @@ -2170,6 +2298,22 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (app.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2286,6 +2430,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2403,6 +2574,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): TaskType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2964,6 +3162,35 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateConnected.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (gitAccountId.asKnown().isPresent) 1 else 0) + + (if (gitId.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (private_.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (branch.asKnown().isPresent) 1 else 0) + + (if (rootDir.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3789,7 +4016,7 @@ private constructor( periodStartDate() projectCount() slug() - status() + status().validate() inviteCode() monthlyUsage().ifPresent { it.forEach { it.validate() } } samlOnlyAccess() @@ -3797,6 +4024,39 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3924,6 +4184,33 @@ private constructor( OpenlayerInvalidDataException("Value is not a String") } + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4148,6 +4435,26 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt index 5cdbc35e..953cc735 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponse.kt @@ -186,6 +186,23 @@ private constructor( validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (storageUri.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt index b7f0de52..0d78d471 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/CommitRetrieveResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.commits +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -98,4 +100,57 @@ internal class CommitRetrieveResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitRetrieveResponse = + CommitRetrieveResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitRetrieveResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitRetrieveResponse.Status.QUEUED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitRetrieveResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + val roundtrippedCommitRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommitRetrieveResponse).isEqualTo(commitRetrieveResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt index 11c30854..db3fb096 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/commits/testresults/TestResultListResponseTest.kt @@ -2,7 +2,9 @@ package com.openlayer.api.models.commits.testresults +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -121,4 +123,72 @@ internal class TestResultListResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val testResultListResponse = + TestResultListResponse.builder() + .addItem( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.RUNNING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .build() + + val roundtrippedTestResultListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(testResultListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTestResultListResponse).isEqualTo(testResultListResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt index cdfc0ddb..e7793364 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineRetrieveResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.inferencepipelines +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.LocalDate import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -206,4 +208,109 @@ internal class InferencePipelineRetrieveResponseTest { assertThat(inferencePipelineRetrieveResponse.workspaceId()) .contains("055fddb1-261f-4654-8598-f6347ee46a09") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineRetrieveResponse = + InferencePipelineRetrieveResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineRetrieveResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineRetrieveResponse.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineRetrieveResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineRetrieveResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineRetrieveResponse.Project.Source.WEB) + .taskType(InferencePipelineRetrieveResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineRetrieveResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineRetrieveResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineRetrieveResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineRetrieveResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val roundtrippedInferencePipelineRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineRetrieveResponse) + .isEqualTo(inferencePipelineRetrieveResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt index ed7a6ec2..c7efc74e 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/InferencePipelineUpdateResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.inferencepipelines +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.LocalDate import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -206,4 +208,109 @@ internal class InferencePipelineUpdateResponseTest { assertThat(inferencePipelineUpdateResponse.workspaceId()) .contains("055fddb1-261f-4654-8598-f6347ee46a09") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineUpdateResponse = + InferencePipelineUpdateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineUpdateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineUpdateResponse.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineUpdateResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineUpdateResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineUpdateResponse.Project.Source.WEB) + .taskType(InferencePipelineUpdateResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineUpdateResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineUpdateResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineUpdateResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineUpdateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val roundtrippedInferencePipelineUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineUpdateResponse) + .isEqualTo(inferencePipelineUpdateResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt index c4973097..650b2051 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/data/DataStreamResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.inferencepipelines.data +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,4 +16,19 @@ internal class DataStreamResponseTest { assertThat(dataStreamResponse.success()).isEqualTo(DataStreamResponse.Success.TRUE) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val dataStreamResponse = + DataStreamResponse.builder().success(DataStreamResponse.Success.TRUE).build() + + val roundtrippedDataStreamResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(dataStreamResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDataStreamResponse).isEqualTo(dataStreamResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt index 28568e08..102493a0 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/rows/RowUpdateResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.inferencepipelines.rows +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,4 +16,19 @@ internal class RowUpdateResponseTest { assertThat(rowUpdateResponse.success()).isEqualTo(RowUpdateResponse.Success.TRUE) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rowUpdateResponse = + RowUpdateResponse.builder().success(RowUpdateResponse.Success.TRUE).build() + + val roundtrippedRowUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(rowUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRowUpdateResponse).isEqualTo(rowUpdateResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt index aaddfb19..18efcffe 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/inferencepipelines/testresults/TestResultListResponseTest.kt @@ -2,7 +2,9 @@ package com.openlayer.api.models.inferencepipelines.testresults +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -121,4 +123,72 @@ internal class TestResultListResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val testResultListResponse = + TestResultListResponse.builder() + .addItem( + TestResultListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataEnds(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateDataStarts(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .inferencePipelineId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .projectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(TestResultListResponse.Item.Status.RUNNING) + .statusMessage("Test successfully processed.") + .goal( + TestResultListResponse.Item.Goal.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commentCount(0L) + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description( + JsonValue.from( + "This test checks for duplicate rows in the dataset." + ) + ) + .name("No duplicate rows") + .number(1L) + .originProjectVersionId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .subtype("duplicateRowCount") + .suggested(false) + .addThreshold( + TestResultListResponse.Item.Goal.Threshold.builder() + .insightName("duplicateRowCount") + .addInsightParameter(JsonValue.from(mapOf())) + .measurement("duplicateRowCount") + .operator("<=") + .value(0.0) + .build() + ) + .type("integrity") + .archived(false) + .delayWindow(0.0) + .evaluationWindow(3600.0) + .usesMlModel(false) + .usesProductionData(false) + .usesReferenceDataset(false) + .usesTrainingDataset(false) + .usesValidationDataset(true) + .build() + ) + .goalId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .build() + ) + .build() + + val roundtrippedTestResultListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(testResultListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTestResultListResponse).isEqualTo(testResultListResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt index f3ecb620..9eae557b 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectCreateResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.projects +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -96,4 +98,57 @@ internal class ProjectCreateResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val projectCreateResponse = + ProjectCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectCreateResponse.Source.WEB) + .taskType(ProjectCreateResponse.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectCreateResponse.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + + val roundtrippedProjectCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(projectCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProjectCreateResponse).isEqualTo(projectCreateResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt index 1a8a28c7..5b68ccac 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/ProjectListResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.projects +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -98,4 +100,61 @@ internal class ProjectListResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val projectListResponse = + ProjectListResponse.builder() + .addItem( + ProjectListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + ProjectListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(ProjectListResponse.Item.Source.WEB) + .taskType(ProjectListResponse.Item.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + ProjectListResponse.Item.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .build() + + val roundtrippedProjectListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(projectListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProjectListResponse).isEqualTo(projectListResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt index b8ec9cd9..ad2e5cb1 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitCreateResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.projects.commits +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -97,4 +99,57 @@ internal class CommitCreateResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitCreateResponse = + CommitCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitCreateResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitCreateResponse.Status.QUEUED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + + val roundtrippedCommitCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommitCreateResponse).isEqualTo(commitCreateResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt index a6ef21e7..89a9b7f0 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/commits/CommitListResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.projects.commits +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -98,4 +100,61 @@ internal class CommitListResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val commitListResponse = + CommitListResponse.builder() + .addItem( + CommitListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + CommitListResponse.Item.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(1024L) + .message("Updated the prompt.") + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .storageUri("s3://...") + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .gitCommitRef("main") + .gitCommitSha(0L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(1L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(CommitListResponse.Item.Status.QUEUED) + .statusMessage("Commit successfully processed.") + .totalGoalCount(6L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(false) + .deploymentStatus("Deployed") + .links( + CommitListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedCommitListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(commitListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCommitListResponse).isEqualTo(commitListResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt index 27e5e421..75f658b8 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineCreateResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.projects.inferencepipelines +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.LocalDate import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -206,4 +208,109 @@ internal class InferencePipelineCreateResponseTest { assertThat(inferencePipelineCreateResponse.workspaceId()) .contains("055fddb1-261f-4654-8598-f6347ee46a09") } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineCreateResponse = + InferencePipelineCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineCreateResponse.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineCreateResponse.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineCreateResponse.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineCreateResponse.Project.Source.WEB) + .taskType(InferencePipelineCreateResponse.Project.TaskType.LLM_BASE) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineCreateResponse.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineCreateResponse.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineCreateResponse.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineCreateResponse.Workspace.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + + val roundtrippedInferencePipelineCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineCreateResponse) + .isEqualTo(inferencePipelineCreateResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt index 54344291..9ace9e03 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/projects/inferencepipelines/InferencePipelineListResponseTest.kt @@ -2,6 +2,8 @@ package com.openlayer.api.models.projects.inferencepipelines +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper import java.time.LocalDate import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat @@ -208,4 +210,120 @@ internal class InferencePipelineListResponseTest { .build() ) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inferencePipelineListResponse = + InferencePipelineListResponse.builder() + .addItem( + InferencePipelineListResponse.Item.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastEvaluated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateLastSampleReceived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateOfNextEvaluation(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .description("This pipeline is used for production.") + .failingGoalCount(1L) + .links( + InferencePipelineListResponse.Item.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6/inference-pipeline/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .name("production") + .passingGoalCount(5L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(InferencePipelineListResponse.Item.Status.QUEUED) + .statusMessage("Tests successfully evaluated") + .totalGoalCount(6L) + .project( + InferencePipelineListResponse.Item.Project.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .creatorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateUpdated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .developmentGoalCount(5L) + .goalCount(10L) + .inferencePipelineCount(1L) + .links( + InferencePipelineListResponse.Item.Project.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .monitoringGoalCount(5L) + .name("My Project") + .source(InferencePipelineListResponse.Item.Project.Source.WEB) + .taskType( + InferencePipelineListResponse.Item.Project.TaskType.LLM_BASE + ) + .versionCount(2L) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .description("My project description.") + .gitRepo( + InferencePipelineListResponse.Item.Project.GitRepo.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateConnected( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .dateUpdated( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .gitAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .gitId(0L) + .name("name") + .private_(true) + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .slug("slug") + .url("url") + .branch("branch") + .rootDir("rootDir") + .build() + ) + .build() + ) + .workspace( + InferencePipelineListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(InferencePipelineListResponse.Item.Workspace.Status.ACTIVE) + .addMonthlyUsage( + InferencePipelineListResponse.Item.Workspace.MonthlyUsage + .builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + ) + .workspaceId("055fddb1-261f-4654-8598-f6347ee46a09") + .build() + ) + .build() + + val roundtrippedInferencePipelineListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inferencePipelineListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInferencePipelineListResponse) + .isEqualTo(inferencePipelineListResponse) + } } diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt index af5fd427..7ae0134d 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/storage/presignedurl/PresignedUrlCreateResponseTest.kt @@ -2,7 +2,9 @@ package com.openlayer.api.models.storage.presignedurl +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -22,4 +24,23 @@ internal class PresignedUrlCreateResponseTest { assertThat(presignedUrlCreateResponse._fields()) .isEqualTo(JsonValue.from(mapOf())) } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val presignedUrlCreateResponse = + PresignedUrlCreateResponse.builder() + .storageUri("storageUri") + .url("url") + .fields(JsonValue.from(mapOf())) + .build() + + val roundtrippedPresignedUrlCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(presignedUrlCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPresignedUrlCreateResponse).isEqualTo(presignedUrlCreateResponse) + } }