From 60c024ae40e251dc8f7fac528a94df8acbd343cc Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Thu, 31 Oct 2024 17:43:00 +0000 Subject: [PATCH] feat(api): manual updates --- .../kotlin/com/openlayer/api/core/Utils.kt | 14 - .../api/core/http/RetryingHttpClient.kt | 7 +- .../api/models/ProjectCommitCreateParams.kt | 673 +++++++++++++ .../api/models/ProjectCommitCreateResponse.kt | 951 ++++++++++++++++++ .../api/services/async/CommitServiceAsync.kt | 13 - .../services/async/CommitServiceAsyncImpl.kt | 44 - .../async/projects/CommitServiceAsync.kt | 9 + .../async/projects/CommitServiceAsyncImpl.kt | 34 + .../api/services/blocking/CommitService.kt | 12 - .../services/blocking/CommitServiceImpl.kt | 42 - .../blocking/projects/CommitService.kt | 9 + .../blocking/projects/CommitServiceImpl.kt | 33 + .../models/ProjectCommitCreateParamsTest.kt | 137 +++ .../models/ProjectCommitCreateResponseTest.kt | 105 ++ .../blocking/projects/CommitServiceTest.kt | 38 + 15 files changed, 1993 insertions(+), 128 deletions(-) create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt 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 4fe94f1..2351f9c 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 @@ -39,18 +39,4 @@ internal fun ListMultimap.toUnmodifiable(): ListMultimap { return Multimaps.unmodifiableListMultimap(this) } -@JvmSynthetic -internal fun ListMultimap.getRequiredHeader(header: String): String { - val value = - entries() - .stream() - .filter { entry -> entry.key.equals(header, ignoreCase = true) } - .map { entry -> entry.value } - .findFirst() - if (!value.isPresent) { - throw OpenlayerInvalidDataException("Could not find $header header") - } - return value.get() -} - internal interface Enum diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt index 037f843..4d12aec 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/http/RetryingHttpClient.kt @@ -1,6 +1,5 @@ package com.openlayer.api.core.http -import com.google.common.util.concurrent.MoreExecutors import com.openlayer.api.core.RequestOptions import com.openlayer.api.errors.OpenlayerIoException import java.io.IOException @@ -116,8 +115,10 @@ private constructor( executeWithRetries(request, requestOptions) } }, - MoreExecutors.directExecutor() - ) + ) { + // Run in the same thread. + it.run() + } .thenCompose(Function.identity()) } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt new file mode 100644 index 0000000..9e4edc1 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateParams.kt @@ -0,0 +1,673 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.toUnmodifiable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import com.openlayer.api.models.* +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +class ProjectCommitCreateParams +constructor( + private val projectId: String, + private val commit: Commit, + private val storageUri: String, + private val archived: Boolean?, + private val deploymentStatus: String?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun projectId(): String = projectId + + fun commit(): Commit = commit + + fun storageUri(): String = storageUri + + fun archived(): Optional = Optional.ofNullable(archived) + + fun deploymentStatus(): Optional = Optional.ofNullable(deploymentStatus) + + @JvmSynthetic + internal fun getBody(): ProjectCommitCreateBody { + return ProjectCommitCreateBody( + commit, + storageUri, + archived, + deploymentStatus, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> projectId + else -> "" + } + } + + @JsonDeserialize(builder = ProjectCommitCreateBody.Builder::class) + @NoAutoDetect + class ProjectCommitCreateBody + internal constructor( + private val commit: Commit?, + private val storageUri: String?, + private val archived: Boolean?, + private val deploymentStatus: String?, + private val additionalProperties: Map, + ) { + + /** The details of a commit (project version). */ + @JsonProperty("commit") fun commit(): Commit? = commit + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") fun storageUri(): String? = storageUri + + /** Whether the commit is archived. */ + @JsonProperty("archived") fun archived(): Boolean? = archived + + /** The deployment status associated with the commit's model. */ + @JsonProperty("deploymentStatus") fun deploymentStatus(): String? = deploymentStatus + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var commit: Commit? = null + private var storageUri: String? = null + private var archived: Boolean? = null + private var deploymentStatus: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectCommitCreateBody: ProjectCommitCreateBody) = apply { + this.commit = projectCommitCreateBody.commit + this.storageUri = projectCommitCreateBody.storageUri + this.archived = projectCommitCreateBody.archived + this.deploymentStatus = projectCommitCreateBody.deploymentStatus + additionalProperties(projectCommitCreateBody.additionalProperties) + } + + /** The details of a commit (project version). */ + @JsonProperty("commit") fun commit(commit: Commit) = apply { this.commit = commit } + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") + fun storageUri(storageUri: String) = apply { this.storageUri = storageUri } + + /** Whether the commit is archived. */ + @JsonProperty("archived") + fun archived(archived: Boolean) = apply { this.archived = archived } + + /** The deployment status associated with the commit's model. */ + @JsonProperty("deploymentStatus") + fun deploymentStatus(deploymentStatus: String) = apply { + this.deploymentStatus = deploymentStatus + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectCommitCreateBody = + ProjectCommitCreateBody( + checkNotNull(commit) { "`commit` is required but was not set" }, + checkNotNull(storageUri) { "`storageUri` is required but was not set" }, + archived, + deploymentStatus, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCommitCreateBody && this.commit == other.commit && this.storageUri == other.storageUri && this.archived == other.archived && this.deploymentStatus == other.deploymentStatus && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(commit, storageUri, archived, deploymentStatus, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectCommitCreateBody{commit=$commit, storageUri=$storageUri, archived=$archived, deploymentStatus=$deploymentStatus, additionalProperties=$additionalProperties}" + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCommitCreateParams && this.projectId == other.projectId && this.commit == other.commit && this.storageUri == other.storageUri && this.archived == other.archived && this.deploymentStatus == other.deploymentStatus && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int { + return /* spotless:off */ Objects.hash(projectId, commit, storageUri, archived, deploymentStatus, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */ + } + + override fun toString() = + "ProjectCommitCreateParams{projectId=$projectId, commit=$commit, storageUri=$storageUri, archived=$archived, deploymentStatus=$deploymentStatus, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var projectId: String? = null + private var commit: Commit? = null + private var storageUri: String? = null + private var archived: Boolean? = null + private var deploymentStatus: String? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectCommitCreateParams: ProjectCommitCreateParams) = apply { + this.projectId = projectCommitCreateParams.projectId + this.commit = projectCommitCreateParams.commit + this.storageUri = projectCommitCreateParams.storageUri + this.archived = projectCommitCreateParams.archived + this.deploymentStatus = projectCommitCreateParams.deploymentStatus + additionalQueryParams(projectCommitCreateParams.additionalQueryParams) + additionalHeaders(projectCommitCreateParams.additionalHeaders) + additionalBodyProperties(projectCommitCreateParams.additionalBodyProperties) + } + + fun projectId(projectId: String) = apply { this.projectId = projectId } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = apply { this.commit = commit } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = apply { this.storageUri = storageUri } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean) = apply { this.archived = archived } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = apply { + this.deploymentStatus = deploymentStatus + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): ProjectCommitCreateParams = + ProjectCommitCreateParams( + checkNotNull(projectId) { "`projectId` is required but was not set" }, + checkNotNull(commit) { "`commit` is required but was not set" }, + checkNotNull(storageUri) { "`storageUri` is required but was not set" }, + archived, + deploymentStatus, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + /** The details of a commit (project version). */ + @JsonDeserialize(builder = Commit.Builder::class) + @NoAutoDetect + class Commit + private constructor( + private val id: String?, + private val authorId: String?, + private val dateCreated: OffsetDateTime?, + private val fileSize: Long?, + private val message: String?, + private val mlModelId: String?, + private val validationDatasetId: String?, + private val trainingDatasetId: String?, + private val storageUri: String?, + private val gitCommitSha: Long?, + private val gitCommitRef: String?, + private val gitCommitUrl: String?, + private val additionalProperties: Map, + ) { + + /** The commit id. */ + @JsonProperty("id") fun id(): String? = id + + /** The author id of the commit. */ + @JsonProperty("authorId") fun authorId(): String? = authorId + + /** The commit creation date. */ + @JsonProperty("dateCreated") fun dateCreated(): OffsetDateTime? = dateCreated + + /** The size of the commit bundle in bytes. */ + @JsonProperty("fileSize") fun fileSize(): Long? = fileSize + + /** The commit message. */ + @JsonProperty("message") fun message(): String? = message + + /** The model id. */ + @JsonProperty("mlModelId") fun mlModelId(): String? = mlModelId + + /** The validation dataset id. */ + @JsonProperty("validationDatasetId") + fun validationDatasetId(): String? = validationDatasetId + + /** The training dataset id. */ + @JsonProperty("trainingDatasetId") fun trainingDatasetId(): String? = trainingDatasetId + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") fun storageUri(): String? = storageUri + + /** The SHA of the corresponding git commit. */ + @JsonProperty("gitCommitSha") fun gitCommitSha(): Long? = gitCommitSha + + /** The ref of the corresponding git commit. */ + @JsonProperty("gitCommitRef") fun gitCommitRef(): String? = gitCommitRef + + /** The URL of the corresponding git commit. */ + @JsonProperty("gitCommitUrl") fun gitCommitUrl(): String? = gitCommitUrl + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: String? = null + private var authorId: String? = null + private var dateCreated: OffsetDateTime? = null + private var fileSize: Long? = null + private var message: String? = null + private var mlModelId: String? = null + private var validationDatasetId: String? = null + private var trainingDatasetId: String? = null + private var storageUri: String? = null + private var gitCommitSha: Long? = null + private var gitCommitRef: String? = null + private var gitCommitUrl: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + this.id = commit.id + this.authorId = commit.authorId + this.dateCreated = commit.dateCreated + this.fileSize = commit.fileSize + this.message = commit.message + this.mlModelId = commit.mlModelId + this.validationDatasetId = commit.validationDatasetId + this.trainingDatasetId = commit.trainingDatasetId + this.storageUri = commit.storageUri + this.gitCommitSha = commit.gitCommitSha + this.gitCommitRef = commit.gitCommitRef + this.gitCommitUrl = commit.gitCommitUrl + additionalProperties(commit.additionalProperties) + } + + /** The commit id. */ + @JsonProperty("id") fun id(id: String) = apply { this.id = id } + + /** The author id of the commit. */ + @JsonProperty("authorId") + fun authorId(authorId: String) = apply { this.authorId = authorId } + + /** The commit creation date. */ + @JsonProperty("dateCreated") + fun dateCreated(dateCreated: OffsetDateTime) = apply { this.dateCreated = dateCreated } + + /** The size of the commit bundle in bytes. */ + @JsonProperty("fileSize") + fun fileSize(fileSize: Long) = apply { this.fileSize = fileSize } + + /** The commit message. */ + @JsonProperty("message") fun message(message: String) = apply { this.message = message } + + /** The model id. */ + @JsonProperty("mlModelId") + fun mlModelId(mlModelId: String) = apply { this.mlModelId = mlModelId } + + /** The validation dataset id. */ + @JsonProperty("validationDatasetId") + fun validationDatasetId(validationDatasetId: String) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The training dataset id. */ + @JsonProperty("trainingDatasetId") + fun trainingDatasetId(trainingDatasetId: String) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") + fun storageUri(storageUri: String) = apply { this.storageUri = storageUri } + + /** The SHA of the corresponding git commit. */ + @JsonProperty("gitCommitSha") + fun gitCommitSha(gitCommitSha: Long) = apply { this.gitCommitSha = gitCommitSha } + + /** The ref of the corresponding git commit. */ + @JsonProperty("gitCommitRef") + fun gitCommitRef(gitCommitRef: String) = apply { this.gitCommitRef = gitCommitRef } + + /** The URL of the corresponding git commit. */ + @JsonProperty("gitCommitUrl") + fun gitCommitUrl(gitCommitUrl: String) = apply { this.gitCommitUrl = gitCommitUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Commit = + Commit( + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(authorId) { "`authorId` is required but was not set" }, + dateCreated, + fileSize, + checkNotNull(message) { "`message` is required but was not set" }, + mlModelId, + validationDatasetId, + trainingDatasetId, + checkNotNull(storageUri) { "`storageUri` is required but was not set" }, + gitCommitSha, + gitCommitRef, + gitCommitUrl, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Commit && this.id == other.id && this.authorId == other.authorId && this.dateCreated == other.dateCreated && this.fileSize == other.fileSize && this.message == other.message && this.mlModelId == other.mlModelId && this.validationDatasetId == other.validationDatasetId && this.trainingDatasetId == other.trainingDatasetId && this.storageUri == other.storageUri && this.gitCommitSha == other.gitCommitSha && this.gitCommitRef == other.gitCommitRef && this.gitCommitUrl == other.gitCommitUrl && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, authorId, dateCreated, fileSize, message, mlModelId, validationDatasetId, trainingDatasetId, storageUri, gitCommitSha, gitCommitRef, gitCommitUrl, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Commit{id=$id, authorId=$authorId, dateCreated=$dateCreated, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, storageUri=$storageUri, gitCommitSha=$gitCommitSha, gitCommitRef=$gitCommitRef, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val QUEUED = Status(JsonField.of("queued")) + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PAUSED = Status(JsonField.of("paused")) + + @JvmField val FAILED = Status(JsonField.of("failed")) + + @JvmField val COMPLETED = Status(JsonField.of("completed")) + + @JvmField val UNKNOWN = Status(JsonField.of("unknown")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + enum class Value { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Links.Builder::class) + @NoAutoDetect + class Links + private constructor( + private val app: String?, + private val additionalProperties: Map, + ) { + + @JsonProperty("app") fun app(): String? = app + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var app: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + this.app = links.app + additionalProperties(links.additionalProperties) + } + + @JsonProperty("app") fun app(app: String) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Links = + Links( + checkNotNull(app) { "`app` is required but was not set" }, + additionalProperties.toUnmodifiable() + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && this.app == other.app && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(app, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt new file mode 100644 index 0000000..e7cd957 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/ProjectCommitCreateResponse.kt @@ -0,0 +1,951 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.toUnmodifiable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = ProjectCommitCreateResponse.Builder::class) +@NoAutoDetect +class ProjectCommitCreateResponse +private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val status: JsonField, + private val statusMessage: JsonField, + private val projectId: JsonField, + private val storageUri: JsonField, + private val commit: JsonField, + private val deploymentStatus: JsonField, + private val mlModelId: JsonField, + private val validationDatasetId: JsonField, + private val trainingDatasetId: JsonField, + private val archived: JsonField, + private val dateArchived: JsonField, + private val passingGoalCount: JsonField, + private val failingGoalCount: JsonField, + private val totalGoalCount: JsonField, + private val links: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** The project version (commit) id. */ + fun id(): String = id.getRequired("id") + + /** The project version (commit) creation date. */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(): Status = status.getRequired("status") + + /** The commit status message. */ + fun statusMessage(): Optional = + Optional.ofNullable(statusMessage.getNullable("statusMessage")) + + /** The project id. */ + fun projectId(): String = projectId.getRequired("projectId") + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(): String = storageUri.getRequired("storageUri") + + /** The details of a commit (project version). */ + fun commit(): Commit = commit.getRequired("commit") + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(): Optional = + Optional.ofNullable(deploymentStatus.getNullable("deploymentStatus")) + + /** The model id. */ + fun mlModelId(): Optional = Optional.ofNullable(mlModelId.getNullable("mlModelId")) + + /** The validation dataset id. */ + fun validationDatasetId(): Optional = + Optional.ofNullable(validationDatasetId.getNullable("validationDatasetId")) + + /** The training dataset id. */ + fun trainingDatasetId(): Optional = + Optional.ofNullable(trainingDatasetId.getNullable("trainingDatasetId")) + + /** Whether the commit is archived. */ + fun archived(): Optional = Optional.ofNullable(archived.getNullable("archived")) + + /** The commit archive date. */ + fun dateArchived(): Optional = + Optional.ofNullable(dateArchived.getNullable("dateArchived")) + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(): Long = passingGoalCount.getRequired("passingGoalCount") + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(): Long = failingGoalCount.getRequired("failingGoalCount") + + /** The total number of tests for the commit. */ + fun totalGoalCount(): Long = totalGoalCount.getRequired("totalGoalCount") + + fun links(): Optional = Optional.ofNullable(links.getNullable("links")) + + /** The project version (commit) id. */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The project version (commit) creation date. */ + @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + @JsonProperty("status") @ExcludeMissing fun _status() = status + + /** The commit status message. */ + @JsonProperty("statusMessage") @ExcludeMissing fun _statusMessage() = statusMessage + + /** The project id. */ + @JsonProperty("projectId") @ExcludeMissing fun _projectId() = projectId + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri + + /** The details of a commit (project version). */ + @JsonProperty("commit") @ExcludeMissing fun _commit() = commit + + /** The deployment status associated with the commit's model. */ + @JsonProperty("deploymentStatus") @ExcludeMissing fun _deploymentStatus() = deploymentStatus + + /** The model id. */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId() = mlModelId + + /** The validation dataset id. */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId() = validationDatasetId + + /** The training dataset id. */ + @JsonProperty("trainingDatasetId") @ExcludeMissing fun _trainingDatasetId() = trainingDatasetId + + /** Whether the commit is archived. */ + @JsonProperty("archived") @ExcludeMissing fun _archived() = archived + + /** The commit archive date. */ + @JsonProperty("dateArchived") @ExcludeMissing fun _dateArchived() = dateArchived + + /** The number of tests that are passing for the commit. */ + @JsonProperty("passingGoalCount") @ExcludeMissing fun _passingGoalCount() = passingGoalCount + + /** The number of tests that are failing for the commit. */ + @JsonProperty("failingGoalCount") @ExcludeMissing fun _failingGoalCount() = failingGoalCount + + /** The total number of tests for the commit. */ + @JsonProperty("totalGoalCount") @ExcludeMissing fun _totalGoalCount() = totalGoalCount + + @JsonProperty("links") @ExcludeMissing fun _links() = links + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): ProjectCommitCreateResponse = apply { + if (!validated) { + id() + dateCreated() + status() + statusMessage() + projectId() + storageUri() + commit().validate() + deploymentStatus() + mlModelId() + validationDatasetId() + trainingDatasetId() + archived() + dateArchived() + passingGoalCount() + failingGoalCount() + totalGoalCount() + links().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var dateCreated: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var statusMessage: JsonField = JsonMissing.of() + private var projectId: JsonField = JsonMissing.of() + private var storageUri: JsonField = JsonMissing.of() + private var commit: JsonField = JsonMissing.of() + private var deploymentStatus: JsonField = JsonMissing.of() + private var mlModelId: JsonField = JsonMissing.of() + private var validationDatasetId: JsonField = JsonMissing.of() + private var trainingDatasetId: JsonField = JsonMissing.of() + private var archived: JsonField = JsonMissing.of() + private var dateArchived: JsonField = JsonMissing.of() + private var passingGoalCount: JsonField = JsonMissing.of() + private var failingGoalCount: JsonField = JsonMissing.of() + private var totalGoalCount: JsonField = JsonMissing.of() + private var links: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(projectCommitCreateResponse: ProjectCommitCreateResponse) = apply { + this.id = projectCommitCreateResponse.id + this.dateCreated = projectCommitCreateResponse.dateCreated + this.status = projectCommitCreateResponse.status + this.statusMessage = projectCommitCreateResponse.statusMessage + this.projectId = projectCommitCreateResponse.projectId + this.storageUri = projectCommitCreateResponse.storageUri + this.commit = projectCommitCreateResponse.commit + this.deploymentStatus = projectCommitCreateResponse.deploymentStatus + this.mlModelId = projectCommitCreateResponse.mlModelId + this.validationDatasetId = projectCommitCreateResponse.validationDatasetId + this.trainingDatasetId = projectCommitCreateResponse.trainingDatasetId + this.archived = projectCommitCreateResponse.archived + this.dateArchived = projectCommitCreateResponse.dateArchived + this.passingGoalCount = projectCommitCreateResponse.passingGoalCount + this.failingGoalCount = projectCommitCreateResponse.failingGoalCount + this.totalGoalCount = projectCommitCreateResponse.totalGoalCount + this.links = projectCommitCreateResponse.links + additionalProperties(projectCommitCreateResponse.additionalProperties) + } + + /** The project version (commit) id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** The project version (commit) id. */ + @JsonProperty("id") @ExcludeMissing fun id(id: JsonField) = apply { this.id = id } + + /** The project version (commit) creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** The project version (commit) creation date. */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * The commit status. Initially, the commit is `queued`, then, it switches to `running`. + * Finally, it can be `paused`, `failed`, or `completed`. + */ + @JsonProperty("status") + @ExcludeMissing + fun status(status: JsonField) = apply { this.status = status } + + /** The commit status message. */ + fun statusMessage(statusMessage: String) = statusMessage(JsonField.of(statusMessage)) + + /** The commit status message. */ + @JsonProperty("statusMessage") + @ExcludeMissing + fun statusMessage(statusMessage: JsonField) = apply { + this.statusMessage = statusMessage + } + + /** The project id. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** The project id. */ + @JsonProperty("projectId") + @ExcludeMissing + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") + @ExcludeMissing + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The details of a commit (project version). */ + fun commit(commit: Commit) = commit(JsonField.of(commit)) + + /** The details of a commit (project version). */ + @JsonProperty("commit") + @ExcludeMissing + fun commit(commit: JsonField) = apply { this.commit = commit } + + /** The deployment status associated with the commit's model. */ + fun deploymentStatus(deploymentStatus: String) = + deploymentStatus(JsonField.of(deploymentStatus)) + + /** The deployment status associated with the commit's model. */ + @JsonProperty("deploymentStatus") + @ExcludeMissing + fun deploymentStatus(deploymentStatus: JsonField) = apply { + this.deploymentStatus = deploymentStatus + } + + /** The model id. */ + fun mlModelId(mlModelId: String) = mlModelId(JsonField.of(mlModelId)) + + /** The model id. */ + @JsonProperty("mlModelId") + @ExcludeMissing + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String) = + validationDatasetId(JsonField.of(validationDatasetId)) + + /** The validation dataset id. */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String) = + trainingDatasetId(JsonField.of(trainingDatasetId)) + + /** The training dataset id. */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** Whether the commit is archived. */ + fun archived(archived: Boolean) = archived(JsonField.of(archived)) + + /** Whether the commit is archived. */ + @JsonProperty("archived") + @ExcludeMissing + fun archived(archived: JsonField) = apply { this.archived = archived } + + /** The commit archive date. */ + fun dateArchived(dateArchived: OffsetDateTime) = dateArchived(JsonField.of(dateArchived)) + + /** The commit archive date. */ + @JsonProperty("dateArchived") + @ExcludeMissing + fun dateArchived(dateArchived: JsonField) = apply { + this.dateArchived = dateArchived + } + + /** The number of tests that are passing for the commit. */ + fun passingGoalCount(passingGoalCount: Long) = + passingGoalCount(JsonField.of(passingGoalCount)) + + /** The number of tests that are passing for the commit. */ + @JsonProperty("passingGoalCount") + @ExcludeMissing + fun passingGoalCount(passingGoalCount: JsonField) = apply { + this.passingGoalCount = passingGoalCount + } + + /** The number of tests that are failing for the commit. */ + fun failingGoalCount(failingGoalCount: Long) = + failingGoalCount(JsonField.of(failingGoalCount)) + + /** The number of tests that are failing for the commit. */ + @JsonProperty("failingGoalCount") + @ExcludeMissing + fun failingGoalCount(failingGoalCount: JsonField) = apply { + this.failingGoalCount = failingGoalCount + } + + /** The total number of tests for the commit. */ + fun totalGoalCount(totalGoalCount: Long) = totalGoalCount(JsonField.of(totalGoalCount)) + + /** The total number of tests for the commit. */ + @JsonProperty("totalGoalCount") + @ExcludeMissing + fun totalGoalCount(totalGoalCount: JsonField) = apply { + this.totalGoalCount = totalGoalCount + } + + fun links(links: Links) = links(JsonField.of(links)) + + @JsonProperty("links") + @ExcludeMissing + fun links(links: JsonField) = apply { this.links = links } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): ProjectCommitCreateResponse = + ProjectCommitCreateResponse( + id, + dateCreated, + status, + statusMessage, + projectId, + storageUri, + commit, + deploymentStatus, + mlModelId, + validationDatasetId, + trainingDatasetId, + archived, + dateArchived, + passingGoalCount, + failingGoalCount, + totalGoalCount, + links, + additionalProperties.toUnmodifiable(), + ) + } + + /** The details of a commit (project version). */ + @JsonDeserialize(builder = Commit.Builder::class) + @NoAutoDetect + class Commit + private constructor( + private val id: JsonField, + private val authorId: JsonField, + private val dateCreated: JsonField, + private val fileSize: JsonField, + private val message: JsonField, + private val mlModelId: JsonField, + private val validationDatasetId: JsonField, + private val trainingDatasetId: JsonField, + private val storageUri: JsonField, + private val gitCommitSha: JsonField, + private val gitCommitRef: JsonField, + private val gitCommitUrl: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The commit id. */ + fun id(): String = id.getRequired("id") + + /** The author id of the commit. */ + fun authorId(): String = authorId.getRequired("authorId") + + /** The commit creation date. */ + fun dateCreated(): Optional = + Optional.ofNullable(dateCreated.getNullable("dateCreated")) + + /** The size of the commit bundle in bytes. */ + fun fileSize(): Optional = Optional.ofNullable(fileSize.getNullable("fileSize")) + + /** The commit message. */ + fun message(): String = message.getRequired("message") + + /** The model id. */ + fun mlModelId(): Optional = Optional.ofNullable(mlModelId.getNullable("mlModelId")) + + /** The validation dataset id. */ + fun validationDatasetId(): Optional = + Optional.ofNullable(validationDatasetId.getNullable("validationDatasetId")) + + /** The training dataset id. */ + fun trainingDatasetId(): Optional = + Optional.ofNullable(trainingDatasetId.getNullable("trainingDatasetId")) + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(): String = storageUri.getRequired("storageUri") + + /** The SHA of the corresponding git commit. */ + fun gitCommitSha(): Optional = + Optional.ofNullable(gitCommitSha.getNullable("gitCommitSha")) + + /** The ref of the corresponding git commit. */ + fun gitCommitRef(): Optional = + Optional.ofNullable(gitCommitRef.getNullable("gitCommitRef")) + + /** The URL of the corresponding git commit. */ + fun gitCommitUrl(): Optional = + Optional.ofNullable(gitCommitUrl.getNullable("gitCommitUrl")) + + /** The commit id. */ + @JsonProperty("id") @ExcludeMissing fun _id() = id + + /** The author id of the commit. */ + @JsonProperty("authorId") @ExcludeMissing fun _authorId() = authorId + + /** The commit creation date. */ + @JsonProperty("dateCreated") @ExcludeMissing fun _dateCreated() = dateCreated + + /** The size of the commit bundle in bytes. */ + @JsonProperty("fileSize") @ExcludeMissing fun _fileSize() = fileSize + + /** The commit message. */ + @JsonProperty("message") @ExcludeMissing fun _message() = message + + /** The model id. */ + @JsonProperty("mlModelId") @ExcludeMissing fun _mlModelId() = mlModelId + + /** The validation dataset id. */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun _validationDatasetId() = validationDatasetId + + /** The training dataset id. */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun _trainingDatasetId() = trainingDatasetId + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") @ExcludeMissing fun _storageUri() = storageUri + + /** The SHA of the corresponding git commit. */ + @JsonProperty("gitCommitSha") @ExcludeMissing fun _gitCommitSha() = gitCommitSha + + /** The ref of the corresponding git commit. */ + @JsonProperty("gitCommitRef") @ExcludeMissing fun _gitCommitRef() = gitCommitRef + + /** The URL of the corresponding git commit. */ + @JsonProperty("gitCommitUrl") @ExcludeMissing fun _gitCommitUrl() = gitCommitUrl + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Commit = apply { + if (!validated) { + id() + authorId() + dateCreated() + fileSize() + message() + mlModelId() + validationDatasetId() + trainingDatasetId() + storageUri() + gitCommitSha() + gitCommitRef() + gitCommitUrl() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var id: JsonField = JsonMissing.of() + private var authorId: JsonField = JsonMissing.of() + private var dateCreated: JsonField = JsonMissing.of() + private var fileSize: JsonField = JsonMissing.of() + private var message: JsonField = JsonMissing.of() + private var mlModelId: JsonField = JsonMissing.of() + private var validationDatasetId: JsonField = JsonMissing.of() + private var trainingDatasetId: JsonField = JsonMissing.of() + private var storageUri: JsonField = JsonMissing.of() + private var gitCommitSha: JsonField = JsonMissing.of() + private var gitCommitRef: JsonField = JsonMissing.of() + private var gitCommitUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(commit: Commit) = apply { + this.id = commit.id + this.authorId = commit.authorId + this.dateCreated = commit.dateCreated + this.fileSize = commit.fileSize + this.message = commit.message + this.mlModelId = commit.mlModelId + this.validationDatasetId = commit.validationDatasetId + this.trainingDatasetId = commit.trainingDatasetId + this.storageUri = commit.storageUri + this.gitCommitSha = commit.gitCommitSha + this.gitCommitRef = commit.gitCommitRef + this.gitCommitUrl = commit.gitCommitUrl + additionalProperties(commit.additionalProperties) + } + + /** The commit id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** The commit id. */ + @JsonProperty("id") + @ExcludeMissing + fun id(id: JsonField) = apply { this.id = id } + + /** The author id of the commit. */ + fun authorId(authorId: String) = authorId(JsonField.of(authorId)) + + /** The author id of the commit. */ + @JsonProperty("authorId") + @ExcludeMissing + fun authorId(authorId: JsonField) = apply { this.authorId = authorId } + + /** The commit creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** The commit creation date. */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The size of the commit bundle in bytes. */ + fun fileSize(fileSize: Long) = fileSize(JsonField.of(fileSize)) + + /** The size of the commit bundle in bytes. */ + @JsonProperty("fileSize") + @ExcludeMissing + fun fileSize(fileSize: JsonField) = apply { this.fileSize = fileSize } + + /** The commit message. */ + fun message(message: String) = message(JsonField.of(message)) + + /** The commit message. */ + @JsonProperty("message") + @ExcludeMissing + fun message(message: JsonField) = apply { this.message = message } + + /** The model id. */ + fun mlModelId(mlModelId: String) = mlModelId(JsonField.of(mlModelId)) + + /** The model id. */ + @JsonProperty("mlModelId") + @ExcludeMissing + fun mlModelId(mlModelId: JsonField) = apply { this.mlModelId = mlModelId } + + /** The validation dataset id. */ + fun validationDatasetId(validationDatasetId: String) = + validationDatasetId(JsonField.of(validationDatasetId)) + + /** The validation dataset id. */ + @JsonProperty("validationDatasetId") + @ExcludeMissing + fun validationDatasetId(validationDatasetId: JsonField) = apply { + this.validationDatasetId = validationDatasetId + } + + /** The training dataset id. */ + fun trainingDatasetId(trainingDatasetId: String) = + trainingDatasetId(JsonField.of(trainingDatasetId)) + + /** The training dataset id. */ + @JsonProperty("trainingDatasetId") + @ExcludeMissing + fun trainingDatasetId(trainingDatasetId: JsonField) = apply { + this.trainingDatasetId = trainingDatasetId + } + + /** The storage URI where the commit bundle is stored. */ + fun storageUri(storageUri: String) = storageUri(JsonField.of(storageUri)) + + /** The storage URI where the commit bundle is stored. */ + @JsonProperty("storageUri") + @ExcludeMissing + fun storageUri(storageUri: JsonField) = apply { this.storageUri = storageUri } + + /** The SHA of the corresponding git commit. */ + fun gitCommitSha(gitCommitSha: Long) = gitCommitSha(JsonField.of(gitCommitSha)) + + /** The SHA of the corresponding git commit. */ + @JsonProperty("gitCommitSha") + @ExcludeMissing + fun gitCommitSha(gitCommitSha: JsonField) = apply { + this.gitCommitSha = gitCommitSha + } + + /** The ref of the corresponding git commit. */ + fun gitCommitRef(gitCommitRef: String) = gitCommitRef(JsonField.of(gitCommitRef)) + + /** The ref of the corresponding git commit. */ + @JsonProperty("gitCommitRef") + @ExcludeMissing + fun gitCommitRef(gitCommitRef: JsonField) = apply { + this.gitCommitRef = gitCommitRef + } + + /** The URL of the corresponding git commit. */ + fun gitCommitUrl(gitCommitUrl: String) = gitCommitUrl(JsonField.of(gitCommitUrl)) + + /** The URL of the corresponding git commit. */ + @JsonProperty("gitCommitUrl") + @ExcludeMissing + fun gitCommitUrl(gitCommitUrl: JsonField) = apply { + this.gitCommitUrl = gitCommitUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Commit = + Commit( + id, + authorId, + dateCreated, + fileSize, + message, + mlModelId, + validationDatasetId, + trainingDatasetId, + storageUri, + gitCommitSha, + gitCommitRef, + gitCommitUrl, + additionalProperties.toUnmodifiable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Commit && this.id == other.id && this.authorId == other.authorId && this.dateCreated == other.dateCreated && this.fileSize == other.fileSize && this.message == other.message && this.mlModelId == other.mlModelId && this.validationDatasetId == other.validationDatasetId && this.trainingDatasetId == other.trainingDatasetId && this.storageUri == other.storageUri && this.gitCommitSha == other.gitCommitSha && this.gitCommitRef == other.gitCommitRef && this.gitCommitUrl == other.gitCommitUrl && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, authorId, dateCreated, fileSize, message, mlModelId, validationDatasetId, trainingDatasetId, storageUri, gitCommitSha, gitCommitRef, gitCommitUrl, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "Commit{id=$id, authorId=$authorId, dateCreated=$dateCreated, fileSize=$fileSize, message=$message, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, storageUri=$storageUri, gitCommitSha=$gitCommitSha, gitCommitRef=$gitCommitRef, gitCommitUrl=$gitCommitUrl, additionalProperties=$additionalProperties}" + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && this.value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val QUEUED = Status(JsonField.of("queued")) + + @JvmField val RUNNING = Status(JsonField.of("running")) + + @JvmField val PAUSED = Status(JsonField.of("paused")) + + @JvmField val FAILED = Status(JsonField.of("failed")) + + @JvmField val COMPLETED = Status(JsonField.of("completed")) + + @JvmField val UNKNOWN = Status(JsonField.of("unknown")) + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + enum class Known { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + } + + enum class Value { + QUEUED, + RUNNING, + PAUSED, + FAILED, + COMPLETED, + UNKNOWN, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + QUEUED -> Value.QUEUED + RUNNING -> Value.RUNNING + PAUSED -> Value.PAUSED + FAILED -> Value.FAILED + COMPLETED -> Value.COMPLETED + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + QUEUED -> Known.QUEUED + RUNNING -> Known.RUNNING + PAUSED -> Known.PAUSED + FAILED -> Known.FAILED + COMPLETED -> Known.COMPLETED + UNKNOWN -> Known.UNKNOWN + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } + + @JsonDeserialize(builder = Links.Builder::class) + @NoAutoDetect + class Links + private constructor( + private val app: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun app(): String = app.getRequired("app") + + @JsonProperty("app") @ExcludeMissing fun _app() = app + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Links = apply { + if (!validated) { + app() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var app: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(links: Links) = apply { + this.app = links.app + additionalProperties(links.additionalProperties) + } + + fun app(app: String) = app(JsonField.of(app)) + + @JsonProperty("app") + @ExcludeMissing + fun app(app: JsonField) = apply { this.app = app } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Links = Links(app, additionalProperties.toUnmodifiable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Links && this.app == other.app && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(app, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = "Links{app=$app, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProjectCommitCreateResponse && this.id == other.id && this.dateCreated == other.dateCreated && this.status == other.status && this.statusMessage == other.statusMessage && this.projectId == other.projectId && this.storageUri == other.storageUri && this.commit == other.commit && this.deploymentStatus == other.deploymentStatus && this.mlModelId == other.mlModelId && this.validationDatasetId == other.validationDatasetId && this.trainingDatasetId == other.trainingDatasetId && this.archived == other.archived && this.dateArchived == other.dateArchived && this.passingGoalCount == other.passingGoalCount && this.failingGoalCount == other.failingGoalCount && this.totalGoalCount == other.totalGoalCount && this.links == other.links && this.additionalProperties == other.additionalProperties /* spotless:on */ + } + + private var hashCode: Int = 0 + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = /* spotless:off */ Objects.hash(id, dateCreated, status, statusMessage, projectId, storageUri, commit, deploymentStatus, mlModelId, validationDatasetId, trainingDatasetId, archived, dateArchived, passingGoalCount, failingGoalCount, totalGoalCount, links, additionalProperties) /* spotless:on */ + } + return hashCode + } + + override fun toString() = + "ProjectCommitCreateResponse{id=$id, dateCreated=$dateCreated, status=$status, statusMessage=$statusMessage, projectId=$projectId, storageUri=$storageUri, commit=$commit, deploymentStatus=$deploymentStatus, mlModelId=$mlModelId, validationDatasetId=$validationDatasetId, trainingDatasetId=$trainingDatasetId, archived=$archived, dateArchived=$dateArchived, passingGoalCount=$passingGoalCount, failingGoalCount=$failingGoalCount, totalGoalCount=$totalGoalCount, links=$links, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt index 3c44897..2fbb5b6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsync.kt @@ -1,23 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.async -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.CommitCreateParams -import com.openlayer.api.models.CommitCreateResponse import com.openlayer.api.services.async.commits.TestResultServiceAsync -import java.util.concurrent.CompletableFuture interface CommitServiceAsync { fun testResults(): TestResultServiceAsync - - /** Create a new commit (project version) in a project. */ - @JvmOverloads - fun create( - params: CommitCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CompletableFuture } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt index 8a30011..9fcf0d4 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt @@ -3,61 +3,17 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.CommitCreateParams -import com.openlayer.api.models.CommitCreateResponse import com.openlayer.api.services.async.commits.TestResultServiceAsync import com.openlayer.api.services.async.commits.TestResultServiceAsyncImpl -import java.util.concurrent.CompletableFuture class CommitServiceAsyncImpl constructor( private val clientOptions: ClientOptions, ) : CommitServiceAsync { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val testResults: TestResultServiceAsync by lazy { TestResultServiceAsyncImpl(clientOptions) } override fun testResults(): TestResultServiceAsync = testResults - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Create a new commit (project version) in a project. */ - override fun create( - params: CommitCreateParams, - requestOptions: RequestOptions - ): CompletableFuture { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects", params.getPathParam(0), "versions") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response - -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt index cc723f2..e10cd5c 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsync.kt @@ -5,12 +5,21 @@ package com.openlayer.api.services.async.projects import com.openlayer.api.core.RequestOptions +import com.openlayer.api.models.ProjectCommitCreateParams +import com.openlayer.api.models.ProjectCommitCreateResponse import com.openlayer.api.models.ProjectCommitListParams import com.openlayer.api.models.ProjectCommitListResponse import java.util.concurrent.CompletableFuture interface CommitServiceAsync { + /** Create a new commit (project version) in a project. */ + @JvmOverloads + fun create( + params: ProjectCommitCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + /** List the commits (project versions) in a project. */ @JvmOverloads fun list( diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt index 969be98..9dcce15 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt @@ -10,7 +10,10 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.json import com.openlayer.api.errors.OpenlayerError +import com.openlayer.api.models.ProjectCommitCreateParams +import com.openlayer.api.models.ProjectCommitCreateResponse import com.openlayer.api.models.ProjectCommitListParams import com.openlayer.api.models.ProjectCommitListResponse import java.util.concurrent.CompletableFuture @@ -22,6 +25,37 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Create a new commit (project version) in a project. */ + override fun create( + params: ProjectCommitCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects", params.getPathParam(0), "versions") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt index 269a7f9..6c80386 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt @@ -1,22 +1,10 @@ // File generated from our OpenAPI spec by Stainless. -@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 - package com.openlayer.api.services.blocking -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.models.CommitCreateParams -import com.openlayer.api.models.CommitCreateResponse import com.openlayer.api.services.blocking.commits.TestResultService interface CommitService { fun testResults(): TestResultService - - /** Create a new commit (project version) in a project. */ - @JvmOverloads - fun create( - params: CommitCreateParams, - requestOptions: RequestOptions = RequestOptions.none() - ): CommitCreateResponse } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt index 9da9ca2..50222a8 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt @@ -3,17 +3,6 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions -import com.openlayer.api.core.RequestOptions -import com.openlayer.api.core.handlers.errorHandler -import com.openlayer.api.core.handlers.jsonHandler -import com.openlayer.api.core.handlers.withErrorHandler -import com.openlayer.api.core.http.HttpMethod -import com.openlayer.api.core.http.HttpRequest -import com.openlayer.api.core.http.HttpResponse.Handler -import com.openlayer.api.core.json -import com.openlayer.api.errors.OpenlayerError -import com.openlayer.api.models.CommitCreateParams -import com.openlayer.api.models.CommitCreateResponse import com.openlayer.api.services.blocking.commits.TestResultService import com.openlayer.api.services.blocking.commits.TestResultServiceImpl @@ -22,38 +11,7 @@ constructor( private val clientOptions: ClientOptions, ) : CommitService { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val testResults: TestResultService by lazy { TestResultServiceImpl(clientOptions) } override fun testResults(): TestResultService = testResults - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) - - /** Create a new commit (project version) in a project. */ - override fun create( - params: CommitCreateParams, - requestOptions: RequestOptions - ): CommitCreateResponse { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .addPathSegments("projects", params.getPathParam(0), "versions") - .putAllQueryParams(clientOptions.queryParams) - .putAllQueryParams(params.getQueryParams()) - .putAllHeaders(clientOptions.headers) - .putAllHeaders(params.getHeaders()) - .body(json(clientOptions.jsonMapper, params.getBody())) - .build() - return clientOptions.httpClient.execute(request, requestOptions).let { response -> - response - .use { createHandler.handle(it) } - .apply { - if (requestOptions.responseValidation ?: clientOptions.responseValidation) { - validate() - } - } - } - } } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt index c9fb11e..9874a6e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitService.kt @@ -5,11 +5,20 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.core.RequestOptions +import com.openlayer.api.models.ProjectCommitCreateParams +import com.openlayer.api.models.ProjectCommitCreateResponse import com.openlayer.api.models.ProjectCommitListParams import com.openlayer.api.models.ProjectCommitListResponse interface CommitService { + /** Create a new commit (project version) in a project. */ + @JvmOverloads + fun create( + params: ProjectCommitCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): ProjectCommitCreateResponse + /** List the commits (project versions) in a project. */ @JvmOverloads fun list( diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt index 34e6206..b7b7716 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt @@ -10,7 +10,10 @@ import com.openlayer.api.core.handlers.withErrorHandler import com.openlayer.api.core.http.HttpMethod import com.openlayer.api.core.http.HttpRequest import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.json import com.openlayer.api.errors.OpenlayerError +import com.openlayer.api.models.ProjectCommitCreateParams +import com.openlayer.api.models.ProjectCommitCreateResponse import com.openlayer.api.models.ProjectCommitListParams import com.openlayer.api.models.ProjectCommitListResponse @@ -21,6 +24,36 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Create a new commit (project version) in a project. */ + override fun create( + params: ProjectCommitCreateParams, + requestOptions: RequestOptions + ): ProjectCommitCreateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("projects", params.getPathParam(0), "versions") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt new file mode 100644 index 0000000..1fff953 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateParamsTest.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.openlayer.api.models.* +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectCommitCreateParamsTest { + + @Test + fun createProjectCommitCreateParams() { + ProjectCommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(123L) + .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(123L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .storageUri("s3://...") + .archived(true) + .deploymentStatus("Deployed") + .build() + } + + @Test + fun getBody() { + val params = + ProjectCommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(123L) + .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(123L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .storageUri("s3://...") + .archived(true) + .deploymentStatus("Deployed") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.commit()) + .isEqualTo( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(123L) + .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(123L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + assertThat(body.storageUri()).isEqualTo("s3://...") + assertThat(body.archived()).isEqualTo(true) + assertThat(body.deploymentStatus()).isEqualTo("Deployed") + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + ProjectCommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .message("Updated the prompt.") + .storageUri("s3://...") + .build() + ) + .storageUri("s3://...") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.commit()) + .isEqualTo( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .message("Updated the prompt.") + .storageUri("s3://...") + .build() + ) + assertThat(body.storageUri()).isEqualTo("s3://...") + } + + @Test + fun getPathParam() { + val params = + ProjectCommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .message("Updated the prompt.") + .storageUri("s3://...") + .build() + ) + .storageUri("s3://...") + .build() + assertThat(params).isNotNull + // path param "projectId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt new file mode 100644 index 0000000..4a36d27 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/ProjectCommitCreateResponseTest.kt @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class ProjectCommitCreateResponseTest { + + @Test + fun createProjectCommitCreateResponse() { + val projectCommitCreateResponse = + ProjectCommitCreateResponse.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .commit( + ProjectCommitCreateResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(123L) + .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(123L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .dateArchived(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .dateCreated(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + .failingGoalCount(123L) + .mlModelId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .passingGoalCount(123L) + .projectId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .status(ProjectCommitCreateResponse.Status.QUEUED) + .statusMessage("Commit successfully processed.") + .storageUri("s3://...") + .totalGoalCount(123L) + .trainingDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .validationDatasetId("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .archived(true) + .deploymentStatus("Deployed") + .links( + ProjectCommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + assertThat(projectCommitCreateResponse).isNotNull + assertThat(projectCommitCreateResponse.id()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(projectCommitCreateResponse.commit()) + .isEqualTo( + ProjectCommitCreateResponse.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(123L) + .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(123L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + assertThat(projectCommitCreateResponse.dateArchived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(projectCommitCreateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(projectCommitCreateResponse.failingGoalCount()).isEqualTo(123L) + assertThat(projectCommitCreateResponse.mlModelId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(projectCommitCreateResponse.passingGoalCount()).isEqualTo(123L) + assertThat(projectCommitCreateResponse.projectId()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(projectCommitCreateResponse.status()) + .isEqualTo(ProjectCommitCreateResponse.Status.QUEUED) + assertThat(projectCommitCreateResponse.statusMessage()) + .contains("Commit successfully processed.") + assertThat(projectCommitCreateResponse.storageUri()).isEqualTo("s3://...") + assertThat(projectCommitCreateResponse.totalGoalCount()).isEqualTo(123L) + assertThat(projectCommitCreateResponse.trainingDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(projectCommitCreateResponse.validationDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(projectCommitCreateResponse.archived()).contains(true) + assertThat(projectCommitCreateResponse.deploymentStatus()).contains("Deployed") + assertThat(projectCommitCreateResponse.links()) + .contains( + ProjectCommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt index 83a9c12..cbede51 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceTest.kt @@ -5,12 +5,50 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.TestServerExtension import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient import com.openlayer.api.models.* +import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) class CommitServiceTest { + @Test + fun callCreate() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitService = client.projects().commits() + val projectCommitCreateResponse = + commitService.create( + ProjectCommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + ProjectCommitCreateParams.Commit.builder() + .id("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .authorId("589ece63-49a2-41b4-98e1-10547761d4b0") + .fileSize(123L) + .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(123L) + .gitCommitUrl("gitCommitUrl") + .build() + ) + .storageUri("s3://...") + .archived(true) + .deploymentStatus("Deployed") + .build() + ) + println(projectCommitCreateResponse) + projectCommitCreateResponse.validate() + } + @Test fun callList() { val client =