diff --git a/.stats.yml b/.stats.yml index 6a8c142..dd47305 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 13 +configured_endpoints: 14 diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitCreateParams.kt new file mode 100644 index 0000000..295c594 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitCreateParams.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 CommitCreateParams +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(): CommitCreateBody { + return CommitCreateBody( + 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 = CommitCreateBody.Builder::class) + @NoAutoDetect + class CommitCreateBody + 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(commitCreateBody: CommitCreateBody) = apply { + this.commit = commitCreateBody.commit + this.storageUri = commitCreateBody.storageUri + this.archived = commitCreateBody.archived + this.deploymentStatus = commitCreateBody.deploymentStatus + additionalProperties(commitCreateBody.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(): CommitCreateBody = + CommitCreateBody( + 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 CommitCreateBody && 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() = + "CommitCreateBody{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 CommitCreateParams && 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() = + "CommitCreateParams{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(commitCreateParams: CommitCreateParams) = apply { + this.projectId = commitCreateParams.projectId + this.commit = commitCreateParams.commit + this.storageUri = commitCreateParams.storageUri + this.archived = commitCreateParams.archived + this.deploymentStatus = commitCreateParams.deploymentStatus + additionalQueryParams(commitCreateParams.additionalQueryParams) + additionalHeaders(commitCreateParams.additionalHeaders) + additionalBodyProperties(commitCreateParams.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(): CommitCreateParams = + CommitCreateParams( + 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/CommitCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitCreateResponse.kt new file mode 100644 index 0000000..da6f58d --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/CommitCreateResponse.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 = CommitCreateResponse.Builder::class) +@NoAutoDetect +class CommitCreateResponse +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(): CommitCreateResponse = 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(commitCreateResponse: CommitCreateResponse) = apply { + this.id = commitCreateResponse.id + this.dateCreated = commitCreateResponse.dateCreated + this.status = commitCreateResponse.status + this.statusMessage = commitCreateResponse.statusMessage + this.projectId = commitCreateResponse.projectId + this.storageUri = commitCreateResponse.storageUri + this.commit = commitCreateResponse.commit + this.deploymentStatus = commitCreateResponse.deploymentStatus + this.mlModelId = commitCreateResponse.mlModelId + this.validationDatasetId = commitCreateResponse.validationDatasetId + this.trainingDatasetId = commitCreateResponse.trainingDatasetId + this.archived = commitCreateResponse.archived + this.dateArchived = commitCreateResponse.dateArchived + this.passingGoalCount = commitCreateResponse.passingGoalCount + this.failingGoalCount = commitCreateResponse.failingGoalCount + this.totalGoalCount = commitCreateResponse.totalGoalCount + this.links = commitCreateResponse.links + additionalProperties(commitCreateResponse.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(): CommitCreateResponse = + CommitCreateResponse( + 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 CommitCreateResponse && 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() = + "CommitCreateResponse{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 2fbb5b6..3c44897 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,10 +1,23 @@ // 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 9fcf0d4..8a30011 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,17 +3,61 @@ 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/blocking/CommitService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitService.kt index 6c80386..269a7f9 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,10 +1,22 @@ // 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 50222a8..9da9ca2 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,6 +3,17 @@ 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 @@ -11,7 +22,38 @@ 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/test/kotlin/com/openlayer/api/models/CommitCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitCreateParamsTest.kt new file mode 100644 index 0000000..6386c58 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitCreateParamsTest.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 CommitCreateParamsTest { + + @Test + fun createCommitCreateParams() { + CommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + CommitCreateParams.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 = + CommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + CommitCreateParams.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( + CommitCreateParams.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 = + CommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + CommitCreateParams.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( + CommitCreateParams.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 = + CommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + CommitCreateParams.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/CommitCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitCreateResponseTest.kt new file mode 100644 index 0000000..279da2a --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/CommitCreateResponseTest.kt @@ -0,0 +1,102 @@ +// 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 CommitCreateResponseTest { + + @Test + fun createCommitCreateResponse() { + 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(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(CommitCreateResponse.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( + CommitCreateResponse.Links.builder() + .app( + "https://app.openlayer.com/myWorkspace/3fa85f64-5717-4562-b3fc-2c963f66afa6" + ) + .build() + ) + .build() + assertThat(commitCreateResponse).isNotNull + assertThat(commitCreateResponse.id()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.commit()) + .isEqualTo( + CommitCreateResponse.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(commitCreateResponse.dateArchived()) + .contains(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(commitCreateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2024-03-22T11:31:01.185Z")) + assertThat(commitCreateResponse.failingGoalCount()).isEqualTo(123L) + assertThat(commitCreateResponse.mlModelId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.passingGoalCount()).isEqualTo(123L) + assertThat(commitCreateResponse.projectId()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.status()).isEqualTo(CommitCreateResponse.Status.QUEUED) + assertThat(commitCreateResponse.statusMessage()).contains("Commit successfully processed.") + assertThat(commitCreateResponse.storageUri()).isEqualTo("s3://...") + assertThat(commitCreateResponse.totalGoalCount()).isEqualTo(123L) + assertThat(commitCreateResponse.trainingDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.validationDatasetId()) + .contains("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(commitCreateResponse.archived()).contains(true) + assertThat(commitCreateResponse.deploymentStatus()).contains("Deployed") + assertThat(commitCreateResponse.links()) + .contains( + CommitCreateResponse.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/CommitServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/CommitServiceTest.kt index 4a62862..13c6f05 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/CommitServiceTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/CommitServiceTest.kt @@ -3,7 +3,49 @@ package com.openlayer.api.services.blocking 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 +@ExtendWith(TestServerExtension::class) +class CommitServiceTest { + + @Test + fun callCreate() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val commitService = client.commits() + val commitCreateResponse = + commitService.create( + CommitCreateParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .commit( + CommitCreateParams.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(commitCreateResponse) + commitCreateResponse.validate() + } +}