diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fd0ccba9..3d2ac0bd 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.12" + ".": "0.1.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 9297db8c..aa5f69b8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,3 +1,3 @@ -configured_endpoints: 19 +configured_endpoints: 24 openapi_spec_hash: 68055a774f3305fb11efa5b5b5881446 -config_hash: 00442fdab71911b02ab1e10f9ec05b79 +config_hash: f0743196c68fb84cbd06a95f134702b3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aa85519..bec1726d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0 (2026-01-08) + +Full Changelog: [v0.1.0-alpha.12...v0.1.0](https://github.com/openlayer-ai/openlayer-java/compare/v0.1.0-alpha.12...v0.1.0) + +### Features + +* **api:** add missing endpoints ([db4b1fb](https://github.com/openlayer-ai/openlayer-java/commit/db4b1fbc7bd03820c3292f5e25bba78d606abb1f)) + ## 0.1.0-alpha.12 (2026-01-07) Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/openlayer-ai/openlayer-java/compare/v0.1.0-alpha.11...v0.1.0-alpha.12) diff --git a/README.md b/README.md index 5fe2d289..1dd08bfe 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.1.0-alpha.12) -[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.1.0-alpha.12/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.1.0-alpha.12) +[![Maven Central](https://img.shields.io/maven-central/v/com.openlayer.api/openlayer-java)](https://central.sonatype.com/artifact/com.openlayer.api/openlayer-java/0.1.0) +[![javadoc](https://javadoc.io/badge2/com.openlayer.api/openlayer-java/0.1.0/javadoc.svg)](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.1.0) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.1.0-alpha.12). +The REST API documentation can be found on [openlayer.com](https://openlayer.com/docs/api-reference/rest/overview). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openlayer.api/openlayer-java/0.1.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [openlayer.com](https://openlayer.com ### Gradle ```kotlin -implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.12") +implementation("com.openlayer.api:openlayer-java:0.1.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openlayer.api:openlayer-java:0.1.0-alpha.12") com.openlayer.api openlayer-java - 0.1.0-alpha.12 + 0.1.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 0f25f17d..368e5b16 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openlayer.api" - version = "0.1.0-alpha.12" // x-release-please-version + version = "0.1.0" // x-release-please-version } subprojects { diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt index 6a97cc73..61c86d06 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClient.kt @@ -8,6 +8,7 @@ import com.openlayer.api.services.blocking.InferencePipelineService import com.openlayer.api.services.blocking.ProjectService import com.openlayer.api.services.blocking.StorageService import com.openlayer.api.services.blocking.TestService +import com.openlayer.api.services.blocking.WorkspaceService import java.util.function.Consumer /** @@ -48,6 +49,8 @@ interface OpenlayerClient { fun projects(): ProjectService + fun workspaces(): WorkspaceService + fun commits(): CommitService fun inferencePipelines(): InferencePipelineService @@ -81,6 +84,8 @@ interface OpenlayerClient { fun projects(): ProjectService.WithRawResponse + fun workspaces(): WorkspaceService.WithRawResponse + fun commits(): CommitService.WithRawResponse fun inferencePipelines(): InferencePipelineService.WithRawResponse diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt index 5894656c..960d3f89 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsync.kt @@ -8,6 +8,7 @@ import com.openlayer.api.services.async.InferencePipelineServiceAsync import com.openlayer.api.services.async.ProjectServiceAsync import com.openlayer.api.services.async.StorageServiceAsync import com.openlayer.api.services.async.TestServiceAsync +import com.openlayer.api.services.async.WorkspaceServiceAsync import java.util.function.Consumer /** @@ -48,6 +49,8 @@ interface OpenlayerClientAsync { fun projects(): ProjectServiceAsync + fun workspaces(): WorkspaceServiceAsync + fun commits(): CommitServiceAsync fun inferencePipelines(): InferencePipelineServiceAsync @@ -85,6 +88,8 @@ interface OpenlayerClientAsync { fun projects(): ProjectServiceAsync.WithRawResponse + fun workspaces(): WorkspaceServiceAsync.WithRawResponse + fun commits(): CommitServiceAsync.WithRawResponse fun inferencePipelines(): InferencePipelineServiceAsync.WithRawResponse diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt index fb7c4680..6c590e95 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientAsyncImpl.kt @@ -14,6 +14,8 @@ import com.openlayer.api.services.async.StorageServiceAsync import com.openlayer.api.services.async.StorageServiceAsyncImpl import com.openlayer.api.services.async.TestServiceAsync import com.openlayer.api.services.async.TestServiceAsyncImpl +import com.openlayer.api.services.async.WorkspaceServiceAsync +import com.openlayer.api.services.async.WorkspaceServiceAsyncImpl import java.util.function.Consumer class OpenlayerClientAsyncImpl(private val clientOptions: ClientOptions) : OpenlayerClientAsync { @@ -37,6 +39,10 @@ class OpenlayerClientAsyncImpl(private val clientOptions: ClientOptions) : Openl ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } + private val workspaces: WorkspaceServiceAsync by lazy { + WorkspaceServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val commits: CommitServiceAsync by lazy { CommitServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -60,6 +66,8 @@ class OpenlayerClientAsyncImpl(private val clientOptions: ClientOptions) : Openl override fun projects(): ProjectServiceAsync = projects + override fun workspaces(): WorkspaceServiceAsync = workspaces + override fun commits(): CommitServiceAsync = commits override fun inferencePipelines(): InferencePipelineServiceAsync = inferencePipelines @@ -77,6 +85,10 @@ class OpenlayerClientAsyncImpl(private val clientOptions: ClientOptions) : Openl ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val workspaces: WorkspaceServiceAsync.WithRawResponse by lazy { + WorkspaceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val commits: CommitServiceAsync.WithRawResponse by lazy { CommitServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -102,6 +114,8 @@ class OpenlayerClientAsyncImpl(private val clientOptions: ClientOptions) : Openl override fun projects(): ProjectServiceAsync.WithRawResponse = projects + override fun workspaces(): WorkspaceServiceAsync.WithRawResponse = workspaces + override fun commits(): CommitServiceAsync.WithRawResponse = commits override fun inferencePipelines(): InferencePipelineServiceAsync.WithRawResponse = diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt index 61191e72..b82d4996 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/client/OpenlayerClientImpl.kt @@ -14,6 +14,8 @@ import com.openlayer.api.services.blocking.StorageService import com.openlayer.api.services.blocking.StorageServiceImpl import com.openlayer.api.services.blocking.TestService import com.openlayer.api.services.blocking.TestServiceImpl +import com.openlayer.api.services.blocking.WorkspaceService +import com.openlayer.api.services.blocking.WorkspaceServiceImpl import java.util.function.Consumer class OpenlayerClientImpl(private val clientOptions: ClientOptions) : OpenlayerClient { @@ -35,6 +37,10 @@ class OpenlayerClientImpl(private val clientOptions: ClientOptions) : OpenlayerC private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } + private val workspaces: WorkspaceService by lazy { + WorkspaceServiceImpl(clientOptionsWithUserAgent) + } + private val commits: CommitService by lazy { CommitServiceImpl(clientOptionsWithUserAgent) } private val inferencePipelines: InferencePipelineService by lazy { @@ -54,6 +60,8 @@ class OpenlayerClientImpl(private val clientOptions: ClientOptions) : OpenlayerC override fun projects(): ProjectService = projects + override fun workspaces(): WorkspaceService = workspaces + override fun commits(): CommitService = commits override fun inferencePipelines(): InferencePipelineService = inferencePipelines @@ -71,6 +79,10 @@ class OpenlayerClientImpl(private val clientOptions: ClientOptions) : OpenlayerC ProjectServiceImpl.WithRawResponseImpl(clientOptions) } + private val workspaces: WorkspaceService.WithRawResponse by lazy { + WorkspaceServiceImpl.WithRawResponseImpl(clientOptions) + } + private val commits: CommitService.WithRawResponse by lazy { CommitServiceImpl.WithRawResponseImpl(clientOptions) } @@ -96,6 +108,8 @@ class OpenlayerClientImpl(private val clientOptions: ClientOptions) : OpenlayerC override fun projects(): ProjectService.WithRawResponse = projects + override fun workspaces(): WorkspaceService.WithRawResponse = workspaces + override fun commits(): CommitService.WithRawResponse = commits override fun inferencePipelines(): InferencePipelineService.WithRawResponse = diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveParams.kt new file mode 100644 index 00000000..f114b045 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +import com.openlayer.api.core.Params +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a workspace by its ID. */ +class WorkspaceRetrieveParams +private constructor( + private val workspaceId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun workspaceId(): Optional = Optional.ofNullable(workspaceId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): WorkspaceRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [WorkspaceRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceRetrieveParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(workspaceRetrieveParams: WorkspaceRetrieveParams) = apply { + workspaceId = workspaceRetrieveParams.workspaceId + additionalHeaders = workspaceRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = workspaceRetrieveParams.additionalQueryParams.toBuilder() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WorkspaceRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WorkspaceRetrieveParams = + WorkspaceRetrieveParams( + workspaceId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceRetrieveParams && + workspaceId == other.workspaceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(workspaceId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WorkspaceRetrieveParams{workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveResponse.kt new file mode 100644 index 00000000..c760efa1 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveResponse.kt @@ -0,0 +1,1250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +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.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.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class WorkspaceRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") @ExcludeMissing creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun periodEndDate(): Optional = periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun periodStartDate(): Optional = periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = wildcardDomains.getOptional("wildcardDomains") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCount") @ExcludeMissing fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memberCount") @ExcludeMissing fun _memberCount(): JsonField = memberCount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") @ExcludeMissing fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WorkspaceRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspaceRetrieveResponse: WorkspaceRetrieveResponse) = apply { + id = workspaceRetrieveResponse.id + creatorId = workspaceRetrieveResponse.creatorId + dateCreated = workspaceRetrieveResponse.dateCreated + dateUpdated = workspaceRetrieveResponse.dateUpdated + inviteCount = workspaceRetrieveResponse.inviteCount + memberCount = workspaceRetrieveResponse.memberCount + name = workspaceRetrieveResponse.name + periodEndDate = workspaceRetrieveResponse.periodEndDate + periodStartDate = workspaceRetrieveResponse.periodStartDate + projectCount = workspaceRetrieveResponse.projectCount + slug = workspaceRetrieveResponse.slug + status = workspaceRetrieveResponse.status + inviteCode = workspaceRetrieveResponse.inviteCode + monthlyUsage = workspaceRetrieveResponse.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspaceRetrieveResponse.samlOnlyAccess + wildcardDomains = workspaceRetrieveResponse.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspaceRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** The workspace name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectCount(projectCount: JsonField) = apply { this.projectCount = projectCount } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WorkspaceRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WorkspaceRetrieveResponse = + WorkspaceRetrieveResponse( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WorkspaceRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun predictionCount(): Optional = predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = executionTimeMs(executionTimeMs as Long?) + + /** Alias for calling [Builder.executionTimeMs] with `executionTimeMs.orElse(null)`. */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monthYear(monthYear: JsonField) = apply { this.monthYear = monthYear } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MonthlyUsage && + executionTimeMs == other.executionTimeMs && + monthYear == other.monthYear && + predictionCount == other.predictionCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceRetrieveResponse && + id == other.id && + creatorId == other.creatorId && + dateCreated == other.dateCreated && + dateUpdated == other.dateUpdated && + inviteCount == other.inviteCount && + memberCount == other.memberCount && + name == other.name && + periodEndDate == other.periodEndDate && + periodStartDate == other.periodStartDate && + projectCount == other.projectCount && + slug == other.slug && + status == other.status && + inviteCode == other.inviteCode && + monthlyUsage == other.monthlyUsage && + samlOnlyAccess == other.samlOnlyAccess && + wildcardDomains == other.wildcardDomains && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WorkspaceRetrieveResponse{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateParams.kt new file mode 100644 index 00000000..8d5d1890 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateParams.kt @@ -0,0 +1,539 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +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.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.Params +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a workspace. */ +class WorkspaceUpdateParams +private constructor( + private val workspaceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun workspaceId(): Optional = Optional.ofNullable(workspaceId) + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inviteCode(): Optional = body.inviteCode() + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun slug(): Optional = body.slug() + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _inviteCode(): JsonField = body._inviteCode() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _slug(): JsonField = body._slug() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): WorkspaceUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [WorkspaceUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceUpdateParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(workspaceUpdateParams: WorkspaceUpdateParams) = apply { + workspaceId = workspaceUpdateParams.workspaceId + body = workspaceUpdateParams.body.toBuilder() + additionalHeaders = workspaceUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = workspaceUpdateParams.additionalQueryParams.toBuilder() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [inviteCode] + * - [name] + * - [slug] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = apply { body.inviteCode(inviteCode) } + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inviteCode(inviteCode: JsonField) = apply { body.inviteCode(inviteCode) } + + /** The workspace name. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + /** The workspace slug. */ + fun slug(slug: String) = apply { body.slug(slug) } + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun slug(slug: JsonField) = apply { body.slug(slug) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WorkspaceUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WorkspaceUpdateParams = + WorkspaceUpdateParams( + workspaceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val inviteCode: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + ) : this(inviteCode, name, slug, mutableMapOf()) + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun slug(): Optional = slug.getOptional("slug") + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") + @ExcludeMissing + fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var inviteCode: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var slug: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + inviteCode = body.inviteCode + name = body.name + slug = body.slug + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + /** The workspace name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(inviteCode, name, slug, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + inviteCode() + name() + slug() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + inviteCode == other.inviteCode && + name == other.name && + slug == other.slug && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(inviteCode, name, slug, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{inviteCode=$inviteCode, name=$name, slug=$slug, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceUpdateParams && + workspaceId == other.workspaceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(workspaceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WorkspaceUpdateParams{workspaceId=$workspaceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateResponse.kt new file mode 100644 index 00000000..2b9e4048 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateResponse.kt @@ -0,0 +1,1250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +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.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.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class WorkspaceUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val creatorId: JsonField, + private val dateCreated: JsonField, + private val dateUpdated: JsonField, + private val inviteCount: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val periodEndDate: JsonField, + private val periodStartDate: JsonField, + private val projectCount: JsonField, + private val slug: JsonField, + private val status: JsonField, + private val inviteCode: JsonField, + private val monthlyUsage: JsonField>, + private val samlOnlyAccess: JsonField, + private val wildcardDomains: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creatorId") @ExcludeMissing creatorId: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("inviteCount") + @ExcludeMissing + inviteCount: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("periodEndDate") + @ExcludeMissing + periodEndDate: JsonField = JsonMissing.of(), + @JsonProperty("periodStartDate") + @ExcludeMissing + periodStartDate: JsonField = JsonMissing.of(), + @JsonProperty("projectCount") + @ExcludeMissing + projectCount: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("inviteCode") + @ExcludeMissing + inviteCode: JsonField = JsonMissing.of(), + @JsonProperty("monthlyUsage") + @ExcludeMissing + monthlyUsage: JsonField> = JsonMissing.of(), + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + samlOnlyAccess: JsonField = JsonMissing.of(), + @JsonProperty("wildcardDomains") + @ExcludeMissing + wildcardDomains: JsonField> = JsonMissing.of(), + ) : this( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + mutableMapOf(), + ) + + /** + * The workspace id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The workspace creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creatorId(): Optional = creatorId.getOptional("creatorId") + + /** + * The workspace creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The workspace last updated date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The number of invites in the workspace. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun inviteCount(): Long = inviteCount.getRequired("inviteCount") + + /** + * The number of members in the workspace. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * The workspace name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The end date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun periodEndDate(): Optional = periodEndDate.getOptional("periodEndDate") + + /** + * The start date of the current billing period. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun periodStartDate(): Optional = periodStartDate.getOptional("periodStartDate") + + /** + * The number of projects in the workspace. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun projectCount(): Long = projectCount.getRequired("projectCount") + + /** + * The workspace slug. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun slug(): String = slug.getRequired("slug") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * The workspace invite code. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun inviteCode(): Optional = inviteCode.getOptional("inviteCode") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun monthlyUsage(): Optional> = monthlyUsage.getOptional("monthlyUsage") + + /** + * Whether the workspace only allows SAML authentication. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun samlOnlyAccess(): Optional = samlOnlyAccess.getOptional("samlOnlyAccess") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun wildcardDomains(): Optional> = wildcardDomains.getOptional("wildcardDomains") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creatorId]. + * + * Unlike [creatorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creatorId") @ExcludeMissing fun _creatorId(): JsonField = creatorId + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [inviteCount]. + * + * Unlike [inviteCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCount") @ExcludeMissing fun _inviteCount(): JsonField = inviteCount + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("memberCount") @ExcludeMissing fun _memberCount(): JsonField = memberCount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [periodEndDate]. + * + * Unlike [periodEndDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("periodEndDate") + @ExcludeMissing + fun _periodEndDate(): JsonField = periodEndDate + + /** + * Returns the raw JSON value of [periodStartDate]. + * + * Unlike [periodStartDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("periodStartDate") + @ExcludeMissing + fun _periodStartDate(): JsonField = periodStartDate + + /** + * Returns the raw JSON value of [projectCount]. + * + * Unlike [projectCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("projectCount") + @ExcludeMissing + fun _projectCount(): JsonField = projectCount + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [inviteCode]. + * + * Unlike [inviteCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("inviteCode") @ExcludeMissing fun _inviteCode(): JsonField = inviteCode + + /** + * Returns the raw JSON value of [monthlyUsage]. + * + * Unlike [monthlyUsage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("monthlyUsage") + @ExcludeMissing + fun _monthlyUsage(): JsonField> = monthlyUsage + + /** + * Returns the raw JSON value of [samlOnlyAccess]. + * + * Unlike [samlOnlyAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("samlOnlyAccess") + @ExcludeMissing + fun _samlOnlyAccess(): JsonField = samlOnlyAccess + + /** + * Returns the raw JSON value of [wildcardDomains]. + * + * Unlike [wildcardDomains], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("wildcardDomains") + @ExcludeMissing + fun _wildcardDomains(): JsonField> = wildcardDomains + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WorkspaceUpdateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WorkspaceUpdateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creatorId: JsonField? = null + private var dateCreated: JsonField? = null + private var dateUpdated: JsonField? = null + private var inviteCount: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var periodEndDate: JsonField? = null + private var periodStartDate: JsonField? = null + private var projectCount: JsonField? = null + private var slug: JsonField? = null + private var status: JsonField? = null + private var inviteCode: JsonField = JsonMissing.of() + private var monthlyUsage: JsonField>? = null + private var samlOnlyAccess: JsonField = JsonMissing.of() + private var wildcardDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspaceUpdateResponse: WorkspaceUpdateResponse) = apply { + id = workspaceUpdateResponse.id + creatorId = workspaceUpdateResponse.creatorId + dateCreated = workspaceUpdateResponse.dateCreated + dateUpdated = workspaceUpdateResponse.dateUpdated + inviteCount = workspaceUpdateResponse.inviteCount + memberCount = workspaceUpdateResponse.memberCount + name = workspaceUpdateResponse.name + periodEndDate = workspaceUpdateResponse.periodEndDate + periodStartDate = workspaceUpdateResponse.periodStartDate + projectCount = workspaceUpdateResponse.projectCount + slug = workspaceUpdateResponse.slug + status = workspaceUpdateResponse.status + inviteCode = workspaceUpdateResponse.inviteCode + monthlyUsage = workspaceUpdateResponse.monthlyUsage.map { it.toMutableList() } + samlOnlyAccess = workspaceUpdateResponse.samlOnlyAccess + wildcardDomains = workspaceUpdateResponse.wildcardDomains.map { it.toMutableList() } + additionalProperties = workspaceUpdateResponse.additionalProperties.toMutableMap() + } + + /** The workspace id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The workspace creator id. */ + fun creatorId(creatorId: String?) = creatorId(JsonField.ofNullable(creatorId)) + + /** Alias for calling [Builder.creatorId] with `creatorId.orElse(null)`. */ + fun creatorId(creatorId: Optional) = creatorId(creatorId.getOrNull()) + + /** + * Sets [Builder.creatorId] to an arbitrary JSON value. + * + * You should usually call [Builder.creatorId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creatorId(creatorId: JsonField) = apply { this.creatorId = creatorId } + + /** The workspace creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The workspace last updated date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The number of invites in the workspace. */ + fun inviteCount(inviteCount: Long) = inviteCount(JsonField.of(inviteCount)) + + /** + * Sets [Builder.inviteCount] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inviteCount(inviteCount: JsonField) = apply { this.inviteCount = inviteCount } + + /** The number of members in the workspace. */ + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun memberCount(memberCount: JsonField) = apply { this.memberCount = memberCount } + + /** The workspace name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The end date of the current billing period. */ + fun periodEndDate(periodEndDate: OffsetDateTime?) = + periodEndDate(JsonField.ofNullable(periodEndDate)) + + /** Alias for calling [Builder.periodEndDate] with `periodEndDate.orElse(null)`. */ + fun periodEndDate(periodEndDate: Optional) = + periodEndDate(periodEndDate.getOrNull()) + + /** + * Sets [Builder.periodEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodEndDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun periodEndDate(periodEndDate: JsonField) = apply { + this.periodEndDate = periodEndDate + } + + /** The start date of the current billing period. */ + fun periodStartDate(periodStartDate: OffsetDateTime?) = + periodStartDate(JsonField.ofNullable(periodStartDate)) + + /** Alias for calling [Builder.periodStartDate] with `periodStartDate.orElse(null)`. */ + fun periodStartDate(periodStartDate: Optional) = + periodStartDate(periodStartDate.getOrNull()) + + /** + * Sets [Builder.periodStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.periodStartDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun periodStartDate(periodStartDate: JsonField) = apply { + this.periodStartDate = periodStartDate + } + + /** The number of projects in the workspace. */ + fun projectCount(projectCount: Long) = projectCount(JsonField.of(projectCount)) + + /** + * Sets [Builder.projectCount] to an arbitrary JSON value. + * + * You should usually call [Builder.projectCount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectCount(projectCount: JsonField) = apply { this.projectCount = projectCount } + + /** The workspace slug. */ + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The workspace invite code. */ + fun inviteCode(inviteCode: String) = inviteCode(JsonField.of(inviteCode)) + + /** + * Sets [Builder.inviteCode] to an arbitrary JSON value. + * + * You should usually call [Builder.inviteCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun inviteCode(inviteCode: JsonField) = apply { this.inviteCode = inviteCode } + + fun monthlyUsage(monthlyUsage: List) = + monthlyUsage(JsonField.of(monthlyUsage)) + + /** + * Sets [Builder.monthlyUsage] to an arbitrary JSON value. + * + * You should usually call [Builder.monthlyUsage] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun monthlyUsage(monthlyUsage: JsonField>) = apply { + this.monthlyUsage = monthlyUsage.map { it.toMutableList() } + } + + /** + * Adds a single [MonthlyUsage] to [Builder.monthlyUsage]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addMonthlyUsage(monthlyUsage: MonthlyUsage) = apply { + this.monthlyUsage = + (this.monthlyUsage ?: JsonField.of(mutableListOf())).also { + checkKnown("monthlyUsage", it).add(monthlyUsage) + } + } + + /** Whether the workspace only allows SAML authentication. */ + fun samlOnlyAccess(samlOnlyAccess: Boolean) = samlOnlyAccess(JsonField.of(samlOnlyAccess)) + + /** + * Sets [Builder.samlOnlyAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.samlOnlyAccess] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun samlOnlyAccess(samlOnlyAccess: JsonField) = apply { + this.samlOnlyAccess = samlOnlyAccess + } + + fun wildcardDomains(wildcardDomains: List) = + wildcardDomains(JsonField.of(wildcardDomains)) + + /** + * Sets [Builder.wildcardDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.wildcardDomains] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun wildcardDomains(wildcardDomains: JsonField>) = apply { + this.wildcardDomains = wildcardDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [wildcardDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWildcardDomain(wildcardDomain: String) = apply { + wildcardDomains = + (wildcardDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("wildcardDomains", it).add(wildcardDomain) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WorkspaceUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creatorId() + * .dateCreated() + * .dateUpdated() + * .inviteCount() + * .memberCount() + * .name() + * .periodEndDate() + * .periodStartDate() + * .projectCount() + * .slug() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WorkspaceUpdateResponse = + WorkspaceUpdateResponse( + checkRequired("id", id), + checkRequired("creatorId", creatorId), + checkRequired("dateCreated", dateCreated), + checkRequired("dateUpdated", dateUpdated), + checkRequired("inviteCount", inviteCount), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("periodEndDate", periodEndDate), + checkRequired("periodStartDate", periodStartDate), + checkRequired("projectCount", projectCount), + checkRequired("slug", slug), + checkRequired("status", status), + inviteCode, + (monthlyUsage ?: JsonMissing.of()).map { it.toImmutable() }, + samlOnlyAccess, + (wildcardDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WorkspaceUpdateResponse = apply { + if (validated) { + return@apply + } + + id() + creatorId() + dateCreated() + dateUpdated() + inviteCount() + memberCount() + name() + periodEndDate() + periodStartDate() + projectCount() + slug() + status().validate() + inviteCode() + monthlyUsage().ifPresent { it.forEach { it.validate() } } + samlOnlyAccess() + wildcardDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (creatorId.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (inviteCount.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (periodEndDate.asKnown().isPresent) 1 else 0) + + (if (periodStartDate.asKnown().isPresent) 1 else 0) + + (if (projectCount.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (inviteCode.asKnown().isPresent) 1 else 0) + + (monthlyUsage.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (samlOnlyAccess.asKnown().isPresent) 1 else 0) + + (wildcardDomains.asKnown().getOrNull()?.size ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val PAST_DUE = of("past_due") + + @JvmField val UNPAID = of("unpaid") + + @JvmField val CANCELED = of("canceled") + + @JvmField val INCOMPLETE = of("incomplete") + + @JvmField val INCOMPLETE_EXPIRED = of("incomplete_expired") + + @JvmField val TRIALING = of("trialing") + + @JvmField val PAUSED = of("paused") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + PAST_DUE, + UNPAID, + CANCELED, + INCOMPLETE, + INCOMPLETE_EXPIRED, + TRIALING, + PAUSED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + PAST_DUE -> Value.PAST_DUE + UNPAID -> Value.UNPAID + CANCELED -> Value.CANCELED + INCOMPLETE -> Value.INCOMPLETE + INCOMPLETE_EXPIRED -> Value.INCOMPLETE_EXPIRED + TRIALING -> Value.TRIALING + PAUSED -> Value.PAUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + PAST_DUE -> Known.PAST_DUE + UNPAID -> Known.UNPAID + CANCELED -> Known.CANCELED + INCOMPLETE -> Known.INCOMPLETE + INCOMPLETE_EXPIRED -> Known.INCOMPLETE_EXPIRED + TRIALING -> Known.TRIALING + PAUSED -> Known.PAUSED + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class MonthlyUsage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val executionTimeMs: JsonField, + private val monthYear: JsonField, + private val predictionCount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("executionTimeMs") + @ExcludeMissing + executionTimeMs: JsonField = JsonMissing.of(), + @JsonProperty("monthYear") + @ExcludeMissing + monthYear: JsonField = JsonMissing.of(), + @JsonProperty("predictionCount") + @ExcludeMissing + predictionCount: JsonField = JsonMissing.of(), + ) : this(executionTimeMs, monthYear, predictionCount, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun executionTimeMs(): Optional = executionTimeMs.getOptional("executionTimeMs") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun monthYear(): Optional = monthYear.getOptional("monthYear") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun predictionCount(): Optional = predictionCount.getOptional("predictionCount") + + /** + * Returns the raw JSON value of [executionTimeMs]. + * + * Unlike [executionTimeMs], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("executionTimeMs") + @ExcludeMissing + fun _executionTimeMs(): JsonField = executionTimeMs + + /** + * Returns the raw JSON value of [monthYear]. + * + * Unlike [monthYear], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("monthYear") + @ExcludeMissing + fun _monthYear(): JsonField = monthYear + + /** + * Returns the raw JSON value of [predictionCount]. + * + * Unlike [predictionCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("predictionCount") + @ExcludeMissing + fun _predictionCount(): JsonField = predictionCount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MonthlyUsage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MonthlyUsage]. */ + class Builder internal constructor() { + + private var executionTimeMs: JsonField = JsonMissing.of() + private var monthYear: JsonField = JsonMissing.of() + private var predictionCount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(monthlyUsage: MonthlyUsage) = apply { + executionTimeMs = monthlyUsage.executionTimeMs + monthYear = monthlyUsage.monthYear + predictionCount = monthlyUsage.predictionCount + additionalProperties = monthlyUsage.additionalProperties.toMutableMap() + } + + fun executionTimeMs(executionTimeMs: Long?) = + executionTimeMs(JsonField.ofNullable(executionTimeMs)) + + /** + * Alias for [Builder.executionTimeMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun executionTimeMs(executionTimeMs: Long) = executionTimeMs(executionTimeMs as Long?) + + /** Alias for calling [Builder.executionTimeMs] with `executionTimeMs.orElse(null)`. */ + fun executionTimeMs(executionTimeMs: Optional) = + executionTimeMs(executionTimeMs.getOrNull()) + + /** + * Sets [Builder.executionTimeMs] to an arbitrary JSON value. + * + * You should usually call [Builder.executionTimeMs] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun executionTimeMs(executionTimeMs: JsonField) = apply { + this.executionTimeMs = executionTimeMs + } + + fun monthYear(monthYear: LocalDate) = monthYear(JsonField.of(monthYear)) + + /** + * Sets [Builder.monthYear] to an arbitrary JSON value. + * + * You should usually call [Builder.monthYear] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun monthYear(monthYear: JsonField) = apply { this.monthYear = monthYear } + + fun predictionCount(predictionCount: Long) = + predictionCount(JsonField.of(predictionCount)) + + /** + * Sets [Builder.predictionCount] to an arbitrary JSON value. + * + * You should usually call [Builder.predictionCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun predictionCount(predictionCount: JsonField) = apply { + this.predictionCount = predictionCount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MonthlyUsage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MonthlyUsage = + MonthlyUsage( + executionTimeMs, + monthYear, + predictionCount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MonthlyUsage = apply { + if (validated) { + return@apply + } + + executionTimeMs() + monthYear() + predictionCount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (executionTimeMs.asKnown().isPresent) 1 else 0) + + (if (monthYear.asKnown().isPresent) 1 else 0) + + (if (predictionCount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MonthlyUsage && + executionTimeMs == other.executionTimeMs && + monthYear == other.monthYear && + predictionCount == other.predictionCount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(executionTimeMs, monthYear, predictionCount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MonthlyUsage{executionTimeMs=$executionTimeMs, monthYear=$monthYear, predictionCount=$predictionCount, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WorkspaceUpdateResponse && + id == other.id && + creatorId == other.creatorId && + dateCreated == other.dateCreated && + dateUpdated == other.dateUpdated && + inviteCount == other.inviteCount && + memberCount == other.memberCount && + name == other.name && + periodEndDate == other.periodEndDate && + periodStartDate == other.periodStartDate && + projectCount == other.projectCount && + slug == other.slug && + status == other.status && + inviteCode == other.inviteCode && + monthlyUsage == other.monthlyUsage && + samlOnlyAccess == other.samlOnlyAccess && + wildcardDomains == other.wildcardDomains && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creatorId, + dateCreated, + dateUpdated, + inviteCount, + memberCount, + name, + periodEndDate, + periodStartDate, + projectCount, + slug, + status, + inviteCode, + monthlyUsage, + samlOnlyAccess, + wildcardDomains, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WorkspaceUpdateResponse{id=$id, creatorId=$creatorId, dateCreated=$dateCreated, dateUpdated=$dateUpdated, inviteCount=$inviteCount, memberCount=$memberCount, name=$name, periodEndDate=$periodEndDate, periodStartDate=$periodStartDate, projectCount=$projectCount, slug=$slug, status=$status, inviteCode=$inviteCode, monthlyUsage=$monthlyUsage, samlOnlyAccess=$samlOnlyAccess, wildcardDomains=$wildcardDomains, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateParams.kt new file mode 100644 index 00000000..286c57fc --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateParams.kt @@ -0,0 +1,413 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.apikeys + +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.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.Params +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new API key in a workspace. */ +class ApiKeyCreateParams +private constructor( + private val workspaceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun workspaceId(): Optional = Optional.ofNullable(workspaceId) + + /** + * The API key name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ApiKeyCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ApiKeyCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyCreateParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(apiKeyCreateParams: ApiKeyCreateParams) = apply { + workspaceId = apiKeyCreateParams.workspaceId + body = apiKeyCreateParams.body.toBuilder() + additionalHeaders = apiKeyCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = apiKeyCreateParams.additionalQueryParams.toBuilder() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The API key name. */ + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ApiKeyCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ApiKeyCreateParams = + ApiKeyCreateParams( + workspaceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * The API key name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The API key name. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyCreateParams && + workspaceId == other.workspaceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(workspaceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ApiKeyCreateParams{workspaceId=$workspaceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateResponse.kt new file mode 100644 index 00000000..608e0e84 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateResponse.kt @@ -0,0 +1,396 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.apikeys + +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.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.checkRequired +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ApiKeyCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val dateLastUsed: JsonField, + private val dateUpdated: JsonField, + private val secureKey: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("dateLastUsed") + @ExcludeMissing + dateLastUsed: JsonField = JsonMissing.of(), + @JsonProperty("dateUpdated") + @ExcludeMissing + dateUpdated: JsonField = JsonMissing.of(), + @JsonProperty("secureKey") @ExcludeMissing secureKey: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, dateCreated, dateLastUsed, dateUpdated, secureKey, name, mutableMapOf()) + + /** + * The API key id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The API key creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The API key last use date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dateLastUsed(): Optional = dateLastUsed.getOptional("dateLastUsed") + + /** + * The API key last update date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateUpdated(): OffsetDateTime = dateUpdated.getRequired("dateUpdated") + + /** + * The API key value. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun secureKey(): String = secureKey.getRequired("secureKey") + + /** + * The API key name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [dateLastUsed]. + * + * Unlike [dateLastUsed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateLastUsed") + @ExcludeMissing + fun _dateLastUsed(): JsonField = dateLastUsed + + /** + * Returns the raw JSON value of [dateUpdated]. + * + * Unlike [dateUpdated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateUpdated") + @ExcludeMissing + fun _dateUpdated(): JsonField = dateUpdated + + /** + * Returns the raw JSON value of [secureKey]. + * + * Unlike [secureKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secureKey") @ExcludeMissing fun _secureKey(): JsonField = secureKey + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ApiKeyCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastUsed() + * .dateUpdated() + * .secureKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ApiKeyCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var dateLastUsed: JsonField? = null + private var dateUpdated: JsonField? = null + private var secureKey: JsonField? = null + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(apiKeyCreateResponse: ApiKeyCreateResponse) = apply { + id = apiKeyCreateResponse.id + dateCreated = apiKeyCreateResponse.dateCreated + dateLastUsed = apiKeyCreateResponse.dateLastUsed + dateUpdated = apiKeyCreateResponse.dateUpdated + secureKey = apiKeyCreateResponse.secureKey + name = apiKeyCreateResponse.name + additionalProperties = apiKeyCreateResponse.additionalProperties.toMutableMap() + } + + /** The API key id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The API key creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The API key last use date. */ + fun dateLastUsed(dateLastUsed: OffsetDateTime?) = + dateLastUsed(JsonField.ofNullable(dateLastUsed)) + + /** Alias for calling [Builder.dateLastUsed] with `dateLastUsed.orElse(null)`. */ + fun dateLastUsed(dateLastUsed: Optional) = + dateLastUsed(dateLastUsed.getOrNull()) + + /** + * Sets [Builder.dateLastUsed] to an arbitrary JSON value. + * + * You should usually call [Builder.dateLastUsed] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateLastUsed(dateLastUsed: JsonField) = apply { + this.dateLastUsed = dateLastUsed + } + + /** The API key last update date. */ + fun dateUpdated(dateUpdated: OffsetDateTime) = dateUpdated(JsonField.of(dateUpdated)) + + /** + * Sets [Builder.dateUpdated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateUpdated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dateUpdated(dateUpdated: JsonField) = apply { + this.dateUpdated = dateUpdated + } + + /** The API key value. */ + fun secureKey(secureKey: String) = secureKey(JsonField.of(secureKey)) + + /** + * Sets [Builder.secureKey] to an arbitrary JSON value. + * + * You should usually call [Builder.secureKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun secureKey(secureKey: JsonField) = apply { this.secureKey = secureKey } + + /** The API key name. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ApiKeyCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .dateLastUsed() + * .dateUpdated() + * .secureKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ApiKeyCreateResponse = + ApiKeyCreateResponse( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("dateLastUsed", dateLastUsed), + checkRequired("dateUpdated", dateUpdated), + checkRequired("secureKey", secureKey), + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ApiKeyCreateResponse = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + dateLastUsed() + dateUpdated() + secureKey() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (dateLastUsed.asKnown().isPresent) 1 else 0) + + (if (dateUpdated.asKnown().isPresent) 1 else 0) + + (if (secureKey.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ApiKeyCreateResponse && + id == other.id && + dateCreated == other.dateCreated && + dateLastUsed == other.dateLastUsed && + dateUpdated == other.dateUpdated && + secureKey == other.secureKey && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + dateCreated, + dateLastUsed, + dateUpdated, + secureKey, + name, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ApiKeyCreateResponse{id=$id, dateCreated=$dateCreated, dateLastUsed=$dateLastUsed, dateUpdated=$dateUpdated, secureKey=$secureKey, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateParams.kt new file mode 100644 index 00000000..c45f895a --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateParams.kt @@ -0,0 +1,631 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +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.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.Params +import com.openlayer.api.core.checkKnown +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Invite users to a workspace. */ +class InviteCreateParams +private constructor( + private val workspaceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun workspaceId(): Optional = Optional.ofNullable(workspaceId) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun emails(): Optional> = body.emails() + + /** + * The member role. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun role(): Optional = body.role() + + /** + * Returns the raw JSON value of [emails]. + * + * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _emails(): JsonField> = body._emails() + + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _role(): JsonField = body._role() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InviteCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InviteCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InviteCreateParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inviteCreateParams: InviteCreateParams) = apply { + workspaceId = inviteCreateParams.workspaceId + body = inviteCreateParams.body.toBuilder() + additionalHeaders = inviteCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = inviteCreateParams.additionalQueryParams.toBuilder() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [emails] + * - [role] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun emails(emails: List) = apply { body.emails(emails) } + + /** + * Sets [Builder.emails] to an arbitrary JSON value. + * + * You should usually call [Builder.emails] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun emails(emails: JsonField>) = apply { body.emails(emails) } + + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: String) = apply { body.addEmail(email) } + + /** The member role. */ + fun role(role: Role) = apply { body.role(role) } + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun role(role: JsonField) = apply { body.role(role) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InviteCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InviteCreateParams = + InviteCreateParams( + workspaceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val emails: JsonField>, + private val role: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("emails") + @ExcludeMissing + emails: JsonField> = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonField = JsonMissing.of(), + ) : this(emails, role, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun emails(): Optional> = emails.getOptional("emails") + + /** + * The member role. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun role(): Optional = role.getOptional("role") + + /** + * Returns the raw JSON value of [emails]. + * + * Unlike [emails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails + + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var emails: JsonField>? = null + private var role: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + emails = body.emails.map { it.toMutableList() } + role = body.role + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun emails(emails: List) = emails(JsonField.of(emails)) + + /** + * Sets [Builder.emails] to an arbitrary JSON value. + * + * You should usually call [Builder.emails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [emails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmail(email: String) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).also { + checkKnown("emails", it).add(email) + } + } + + /** The member role. */ + fun role(role: Role) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun role(role: JsonField) = apply { this.role = role } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (emails ?: JsonMissing.of()).map { it.toImmutable() }, + role, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + emails() + role().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (emails.asKnown().getOrNull()?.size ?: 0) + + (role.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + emails == other.emails && + role == other.role && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(emails, role, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{emails=$emails, role=$role, additionalProperties=$additionalProperties}" + } + + /** The member role. */ + class Role @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ADMIN = of("ADMIN") + + @JvmField val MEMBER = of("MEMBER") + + @JvmField val VIEWER = of("VIEWER") + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + /** An enum containing [Role]'s known values. */ + enum class Known { + ADMIN, + MEMBER, + VIEWER, + } + + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ADMIN, + MEMBER, + VIEWER, + /** An enum member indicating that [Role] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ADMIN -> Value.ADMIN + MEMBER -> Value.MEMBER + VIEWER -> Value.VIEWER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ADMIN -> Known.ADMIN + MEMBER -> Known.MEMBER + VIEWER -> Known.VIEWER + else -> throw OpenlayerInvalidDataException("Unknown Role: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Role && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InviteCreateParams && + workspaceId == other.workspaceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(workspaceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InviteCreateParams{workspaceId=$workspaceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateResponse.kt new file mode 100644 index 00000000..8fe2eb44 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateResponse.kt @@ -0,0 +1,1398 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +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.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.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InviteCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InviteCreateResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InviteCreateResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inviteCreateResponse: InviteCreateResponse) = apply { + items = inviteCreateResponse.items.map { it.toMutableList() } + additionalProperties = inviteCreateResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InviteCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InviteCreateResponse = + InviteCreateResponse( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InviteCreateResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val creator: JsonField, + private val dateCreated: JsonField, + private val email: JsonField, + private val role: JsonField, + private val status: JsonField, + private val workspace: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creator") @ExcludeMissing creator: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + ) : this(id, creator, dateCreated, email, role, status, workspace, mutableMapOf()) + + /** + * The invite id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creator(): Creator = creator.getRequired("creator") + + /** + * The invite creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The invite email. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * The invite role. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun role(): Role = role.getRequired("role") + + /** + * The invite status. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun workspace(): Workspace = workspace.getRequired("workspace") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creator]. + * + * Unlike [creator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creator") @ExcludeMissing fun _creator(): JsonField = creator + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") + @ExcludeMissing + fun _workspace(): JsonField = workspace + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .id() + * .creator() + * .dateCreated() + * .email() + * .role() + * .status() + * .workspace() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creator: JsonField? = null + private var dateCreated: JsonField? = null + private var email: JsonField? = null + private var role: JsonField? = null + private var status: JsonField? = null + private var workspace: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + creator = item.creator + dateCreated = item.dateCreated + email = item.email + role = item.role + status = item.status + workspace = item.workspace + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The invite id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun creator(creator: Creator) = creator(JsonField.of(creator)) + + /** + * Sets [Builder.creator] to an arbitrary JSON value. + * + * You should usually call [Builder.creator] with a well-typed [Creator] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creator(creator: JsonField) = apply { this.creator = creator } + + /** The invite creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The invite email. */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** The invite role. */ + fun role(role: Role) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun role(role: JsonField) = apply { this.role = role } + + /** The invite status. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun workspace(workspace: Workspace) = workspace(JsonField.of(workspace)) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creator() + * .dateCreated() + * .email() + * .role() + * .status() + * .workspace() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("creator", creator), + checkRequired("dateCreated", dateCreated), + checkRequired("email", email), + checkRequired("role", role), + checkRequired("status", status), + checkRequired("workspace", workspace), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + creator().validate() + dateCreated() + email() + role().validate() + status().validate() + workspace().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (creator.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (role.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + class Creator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val username: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("username") + @ExcludeMissing + username: JsonField = JsonMissing.of(), + ) : this(id, name, username, mutableMapOf()) + + /** + * The invite creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * The invite creator name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The invite creator username. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun username(): Optional = username.getOptional("username") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Creator]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Creator]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creator: Creator) = apply { + id = creator.id + name = creator.name + username = creator.username + additionalProperties = creator.additionalProperties.toMutableMap() + } + + /** The invite creator id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The invite creator name. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The invite creator username. */ + fun username(username: String?) = username(JsonField.ofNullable(username)) + + /** Alias for calling [Builder.username] with `username.orElse(null)`. */ + fun username(username: Optional) = username(username.getOrNull()) + + /** + * Sets [Builder.username] to an arbitrary JSON value. + * + * You should usually call [Builder.username] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun username(username: JsonField) = apply { this.username = username } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Creator]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Creator = + Creator(id, name, username, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Creator = apply { + if (validated) { + return@apply + } + + id() + name() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Creator && + id == other.id && + name == other.name && + username == other.username && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, name, username, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Creator{id=$id, name=$name, username=$username, additionalProperties=$additionalProperties}" + } + + /** The invite role. */ + class Role @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ADMIN = of("ADMIN") + + @JvmField val MEMBER = of("MEMBER") + + @JvmField val VIEWER = of("VIEWER") + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + /** An enum containing [Role]'s known values. */ + enum class Known { + ADMIN, + MEMBER, + VIEWER, + } + + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ADMIN, + MEMBER, + VIEWER, + /** An enum member indicating that [Role] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ADMIN -> Value.ADMIN + MEMBER -> Value.MEMBER + VIEWER -> Value.VIEWER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ADMIN -> Known.ADMIN + MEMBER -> Known.MEMBER + VIEWER -> Known.VIEWER + else -> throw OpenlayerInvalidDataException("Unknown Role: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Role && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The invite status. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACCEPTED = of("accepted") + + @JvmField val PENDING = of("pending") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACCEPTED, + PENDING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCEPTED, + PENDING, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCEPTED -> Value.ACCEPTED + PENDING -> Value.PENDING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + PENDING -> Known.PENDING + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Workspace + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + ) : this(id, dateCreated, memberCount, name, slug, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun slug(): String = slug.getRequired("slug") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .memberCount() + * .name() + * .slug() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var slug: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + dateCreated = workspace.dateCreated + memberCount = workspace.memberCount + name = workspace.name + slug = workspace.slug + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun memberCount(memberCount: JsonField) = apply { + this.memberCount = memberCount + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .memberCount() + * .name() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("slug", slug), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + memberCount() + name() + slug() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Workspace && + id == other.id && + dateCreated == other.dateCreated && + memberCount == other.memberCount && + name == other.name && + slug == other.slug && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, dateCreated, memberCount, name, slug, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, dateCreated=$dateCreated, memberCount=$memberCount, name=$name, slug=$slug, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + id == other.id && + creator == other.creator && + dateCreated == other.dateCreated && + email == other.email && + role == other.role && + status == other.status && + workspace == other.workspace && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creator, + dateCreated, + email, + role, + status, + workspace, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, creator=$creator, dateCreated=$dateCreated, email=$email, role=$role, status=$status, workspace=$workspace, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InviteCreateResponse && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InviteCreateResponse{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteListParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteListParams.kt new file mode 100644 index 00000000..47d175bf --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteListParams.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +import com.openlayer.api.core.Params +import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a list of invites in a workspace. */ +class InviteListParams +private constructor( + private val workspaceId: String?, + private val page: Long?, + private val perPage: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun workspaceId(): Optional = Optional.ofNullable(workspaceId) + + /** The page to return in a paginated query. */ + fun page(): Optional = Optional.ofNullable(page) + + /** Maximum number of items to return per page. */ + fun perPage(): Optional = Optional.ofNullable(perPage) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): InviteListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InviteListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InviteListParams]. */ + class Builder internal constructor() { + + private var workspaceId: String? = null + private var page: Long? = null + private var perPage: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inviteListParams: InviteListParams) = apply { + workspaceId = inviteListParams.workspaceId + page = inviteListParams.page + perPage = inviteListParams.perPage + additionalHeaders = inviteListParams.additionalHeaders.toBuilder() + additionalQueryParams = inviteListParams.additionalQueryParams.toBuilder() + } + + fun workspaceId(workspaceId: String?) = apply { this.workspaceId = workspaceId } + + /** Alias for calling [Builder.workspaceId] with `workspaceId.orElse(null)`. */ + fun workspaceId(workspaceId: Optional) = workspaceId(workspaceId.getOrNull()) + + /** The page to return in a paginated query. */ + fun page(page: Long?) = apply { this.page = page } + + /** + * Alias for [Builder.page]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun page(page: Long) = page(page as Long?) + + /** Alias for calling [Builder.page] with `page.orElse(null)`. */ + fun page(page: Optional) = page(page.getOrNull()) + + /** Maximum number of items to return per page. */ + fun perPage(perPage: Long?) = apply { this.perPage = perPage } + + /** + * Alias for [Builder.perPage]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun perPage(perPage: Long) = perPage(perPage as Long?) + + /** Alias for calling [Builder.perPage] with `perPage.orElse(null)`. */ + fun perPage(perPage: Optional) = perPage(perPage.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InviteListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InviteListParams = + InviteListParams( + workspaceId, + page, + perPage, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> workspaceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + page?.let { put("page", it.toString()) } + perPage?.let { put("perPage", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InviteListParams && + workspaceId == other.workspaceId && + page == other.page && + perPage == other.perPage && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(workspaceId, page, perPage, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InviteListParams{workspaceId=$workspaceId, page=$page, perPage=$perPage, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteListResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteListResponse.kt new file mode 100644 index 00000000..a1625844 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/workspaces/invites/InviteListResponse.kt @@ -0,0 +1,1709 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +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.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.checkKnown +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.toImmutable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InviteListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val _meta: JsonField<_Meta>, + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("_meta") @ExcludeMissing _meta: JsonField<_Meta> = JsonMissing.of(), + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + ) : this(_meta, items, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun _meta(): _Meta = _meta.getRequired("_meta") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * Returns the raw JSON value of [_meta]. + * + * Unlike [_meta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("_meta") @ExcludeMissing fun __meta(): JsonField<_Meta> = _meta + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InviteListResponse]. + * + * The following fields are required: + * ```java + * ._meta() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InviteListResponse]. */ + class Builder internal constructor() { + + private var _meta: JsonField<_Meta>? = null + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inviteListResponse: InviteListResponse) = apply { + _meta = inviteListResponse._meta + items = inviteListResponse.items.map { it.toMutableList() } + additionalProperties = inviteListResponse.additionalProperties.toMutableMap() + } + + fun _meta(_meta: _Meta) = _meta(JsonField.of(_meta)) + + /** + * Sets [Builder._meta] to an arbitrary JSON value. + * + * You should usually call [Builder._meta] with a well-typed [_Meta] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun _meta(_meta: JsonField<_Meta>) = apply { this._meta = _meta } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InviteListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * ._meta() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InviteListResponse = + InviteListResponse( + checkRequired("_meta", _meta), + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InviteListResponse = apply { + if (validated) { + return@apply + } + + _meta().validate() + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (_meta.asKnown().getOrNull()?.validity() ?: 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class _Meta + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val page: JsonField, + private val perPage: JsonField, + private val totalItems: JsonField, + private val totalPages: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("page") @ExcludeMissing page: JsonField = JsonMissing.of(), + @JsonProperty("perPage") @ExcludeMissing perPage: JsonField = JsonMissing.of(), + @JsonProperty("totalItems") + @ExcludeMissing + totalItems: JsonField = JsonMissing.of(), + @JsonProperty("totalPages") + @ExcludeMissing + totalPages: JsonField = JsonMissing.of(), + ) : this(page, perPage, totalItems, totalPages, mutableMapOf()) + + /** + * The current page. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun page(): Long = page.getRequired("page") + + /** + * The number of items per page. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun perPage(): Long = perPage.getRequired("perPage") + + /** + * The total number of items. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun totalItems(): Long = totalItems.getRequired("totalItems") + + /** + * The total number of pages. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun totalPages(): Long = totalPages.getRequired("totalPages") + + /** + * Returns the raw JSON value of [page]. + * + * Unlike [page], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page") @ExcludeMissing fun _page(): JsonField = page + + /** + * Returns the raw JSON value of [perPage]. + * + * Unlike [perPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("perPage") @ExcludeMissing fun _perPage(): JsonField = perPage + + /** + * Returns the raw JSON value of [totalItems]. + * + * Unlike [totalItems], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalItems") @ExcludeMissing fun _totalItems(): JsonField = totalItems + + /** + * Returns the raw JSON value of [totalPages]. + * + * Unlike [totalPages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("totalPages") @ExcludeMissing fun _totalPages(): JsonField = totalPages + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [_Meta]. + * + * The following fields are required: + * ```java + * .page() + * .perPage() + * .totalItems() + * .totalPages() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [_Meta]. */ + class Builder internal constructor() { + + private var page: JsonField? = null + private var perPage: JsonField? = null + private var totalItems: JsonField? = null + private var totalPages: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(_meta: _Meta) = apply { + page = _meta.page + perPage = _meta.perPage + totalItems = _meta.totalItems + totalPages = _meta.totalPages + additionalProperties = _meta.additionalProperties.toMutableMap() + } + + /** The current page. */ + fun page(page: Long) = page(JsonField.of(page)) + + /** + * Sets [Builder.page] to an arbitrary JSON value. + * + * You should usually call [Builder.page] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun page(page: JsonField) = apply { this.page = page } + + /** The number of items per page. */ + fun perPage(perPage: Long) = perPage(JsonField.of(perPage)) + + /** + * Sets [Builder.perPage] to an arbitrary JSON value. + * + * You should usually call [Builder.perPage] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun perPage(perPage: JsonField) = apply { this.perPage = perPage } + + /** The total number of items. */ + fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) + + /** + * Sets [Builder.totalItems] to an arbitrary JSON value. + * + * You should usually call [Builder.totalItems] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } + + /** The total number of pages. */ + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** + * Sets [Builder.totalPages] to an arbitrary JSON value. + * + * You should usually call [Builder.totalPages] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [_Meta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .page() + * .perPage() + * .totalItems() + * .totalPages() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): _Meta = + _Meta( + checkRequired("page", page), + checkRequired("perPage", perPage), + checkRequired("totalItems", totalItems), + checkRequired("totalPages", totalPages), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): _Meta = apply { + if (validated) { + return@apply + } + + page() + perPage() + totalItems() + totalPages() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (page.asKnown().isPresent) 1 else 0) + + (if (perPage.asKnown().isPresent) 1 else 0) + + (if (totalItems.asKnown().isPresent) 1 else 0) + + (if (totalPages.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is _Meta && + page == other.page && + perPage == other.perPage && + totalItems == other.totalItems && + totalPages == other.totalPages && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(page, perPage, totalItems, totalPages, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "_Meta{page=$page, perPage=$perPage, totalItems=$totalItems, totalPages=$totalPages, additionalProperties=$additionalProperties}" + } + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val creator: JsonField, + private val dateCreated: JsonField, + private val email: JsonField, + private val role: JsonField, + private val status: JsonField, + private val workspace: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("creator") @ExcludeMissing creator: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("role") @ExcludeMissing role: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("workspace") + @ExcludeMissing + workspace: JsonField = JsonMissing.of(), + ) : this(id, creator, dateCreated, email, role, status, workspace, mutableMapOf()) + + /** + * The invite id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creator(): Creator = creator.getRequired("creator") + + /** + * The invite creation date. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * The invite email. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * The invite role. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun role(): Role = role.getRequired("role") + + /** + * The invite status. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun workspace(): Workspace = workspace.getRequired("workspace") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [creator]. + * + * Unlike [creator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("creator") @ExcludeMissing fun _creator(): JsonField = creator + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [role]. + * + * Unlike [role], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role") @ExcludeMissing fun _role(): JsonField = role + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [workspace]. + * + * Unlike [workspace], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace") + @ExcludeMissing + fun _workspace(): JsonField = workspace + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .id() + * .creator() + * .dateCreated() + * .email() + * .role() + * .status() + * .workspace() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var creator: JsonField? = null + private var dateCreated: JsonField? = null + private var email: JsonField? = null + private var role: JsonField? = null + private var status: JsonField? = null + private var workspace: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + creator = item.creator + dateCreated = item.dateCreated + email = item.email + role = item.role + status = item.status + workspace = item.workspace + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The invite id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun creator(creator: Creator) = creator(JsonField.of(creator)) + + /** + * Sets [Builder.creator] to an arbitrary JSON value. + * + * You should usually call [Builder.creator] with a well-typed [Creator] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creator(creator: JsonField) = apply { this.creator = creator } + + /** The invite creation date. */ + fun dateCreated(dateCreated: OffsetDateTime) = dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + /** The invite email. */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** The invite role. */ + fun role(role: Role) = role(JsonField.of(role)) + + /** + * Sets [Builder.role] to an arbitrary JSON value. + * + * You should usually call [Builder.role] with a well-typed [Role] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun role(role: JsonField) = apply { this.role = role } + + /** The invite status. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun workspace(workspace: Workspace) = workspace(JsonField.of(workspace)) + + /** + * Sets [Builder.workspace] to an arbitrary JSON value. + * + * You should usually call [Builder.workspace] with a well-typed [Workspace] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspace(workspace: JsonField) = apply { this.workspace = workspace } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .creator() + * .dateCreated() + * .email() + * .role() + * .status() + * .workspace() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("creator", creator), + checkRequired("dateCreated", dateCreated), + checkRequired("email", email), + checkRequired("role", role), + checkRequired("status", status), + checkRequired("workspace", workspace), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + creator().validate() + dateCreated() + email() + role().validate() + status().validate() + workspace().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (creator.asKnown().getOrNull()?.validity() ?: 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (role.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (workspace.asKnown().getOrNull()?.validity() ?: 0) + + class Creator + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val username: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("username") + @ExcludeMissing + username: JsonField = JsonMissing.of(), + ) : this(id, name, username, mutableMapOf()) + + /** + * The invite creator id. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * The invite creator name. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The invite creator username. + * + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun username(): Optional = username.getOptional("username") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Creator]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Creator]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creator: Creator) = apply { + id = creator.id + name = creator.name + username = creator.username + additionalProperties = creator.additionalProperties.toMutableMap() + } + + /** The invite creator id. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The invite creator name. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The invite creator username. */ + fun username(username: String?) = username(JsonField.ofNullable(username)) + + /** Alias for calling [Builder.username] with `username.orElse(null)`. */ + fun username(username: Optional) = username(username.getOrNull()) + + /** + * Sets [Builder.username] to an arbitrary JSON value. + * + * You should usually call [Builder.username] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun username(username: JsonField) = apply { this.username = username } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Creator]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Creator = + Creator(id, name, username, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Creator = apply { + if (validated) { + return@apply + } + + id() + name() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Creator && + id == other.id && + name == other.name && + username == other.username && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, name, username, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Creator{id=$id, name=$name, username=$username, additionalProperties=$additionalProperties}" + } + + /** The invite role. */ + class Role @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ADMIN = of("ADMIN") + + @JvmField val MEMBER = of("MEMBER") + + @JvmField val VIEWER = of("VIEWER") + + @JvmStatic fun of(value: String) = Role(JsonField.of(value)) + } + + /** An enum containing [Role]'s known values. */ + enum class Known { + ADMIN, + MEMBER, + VIEWER, + } + + /** + * An enum containing [Role]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Role] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ADMIN, + MEMBER, + VIEWER, + /** An enum member indicating that [Role] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ADMIN -> Value.ADMIN + MEMBER -> Value.MEMBER + VIEWER -> Value.VIEWER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ADMIN -> Known.ADMIN + MEMBER -> Known.MEMBER + VIEWER -> Known.VIEWER + else -> throw OpenlayerInvalidDataException("Unknown Role: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Role = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Role && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The invite status. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACCEPTED = of("accepted") + + @JvmField val PENDING = of("pending") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACCEPTED, + PENDING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCEPTED, + PENDING, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCEPTED -> Value.ACCEPTED + PENDING -> Value.PENDING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws OpenlayerInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + PENDING -> Known.PENDING + else -> throw OpenlayerInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws OpenlayerInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenlayerInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Workspace + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val dateCreated: JsonField, + private val memberCount: JsonField, + private val name: JsonField, + private val slug: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("dateCreated") + @ExcludeMissing + dateCreated: JsonField = JsonMissing.of(), + @JsonProperty("memberCount") + @ExcludeMissing + memberCount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("slug") @ExcludeMissing slug: JsonField = JsonMissing.of(), + ) : this(id, dateCreated, memberCount, name, slug, mutableMapOf()) + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dateCreated(): OffsetDateTime = dateCreated.getRequired("dateCreated") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun memberCount(): Long = memberCount.getRequired("memberCount") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws OpenlayerInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun slug(): String = slug.getRequired("slug") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [dateCreated]. + * + * Unlike [dateCreated], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("dateCreated") + @ExcludeMissing + fun _dateCreated(): JsonField = dateCreated + + /** + * Returns the raw JSON value of [memberCount]. + * + * Unlike [memberCount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("memberCount") + @ExcludeMissing + fun _memberCount(): JsonField = memberCount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [slug]. + * + * Unlike [slug], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slug") @ExcludeMissing fun _slug(): JsonField = slug + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Workspace]. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .memberCount() + * .name() + * .slug() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Workspace]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var dateCreated: JsonField? = null + private var memberCount: JsonField? = null + private var name: JsonField? = null + private var slug: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(workspace: Workspace) = apply { + id = workspace.id + dateCreated = workspace.dateCreated + memberCount = workspace.memberCount + name = workspace.name + slug = workspace.slug + additionalProperties = workspace.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun dateCreated(dateCreated: OffsetDateTime) = + dateCreated(JsonField.of(dateCreated)) + + /** + * Sets [Builder.dateCreated] to an arbitrary JSON value. + * + * You should usually call [Builder.dateCreated] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun dateCreated(dateCreated: JsonField) = apply { + this.dateCreated = dateCreated + } + + fun memberCount(memberCount: Long) = memberCount(JsonField.of(memberCount)) + + /** + * Sets [Builder.memberCount] to an arbitrary JSON value. + * + * You should usually call [Builder.memberCount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun memberCount(memberCount: JsonField) = apply { + this.memberCount = memberCount + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun slug(slug: String) = slug(JsonField.of(slug)) + + /** + * Sets [Builder.slug] to an arbitrary JSON value. + * + * You should usually call [Builder.slug] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slug(slug: JsonField) = apply { this.slug = slug } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Workspace]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .dateCreated() + * .memberCount() + * .name() + * .slug() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Workspace = + Workspace( + checkRequired("id", id), + checkRequired("dateCreated", dateCreated), + checkRequired("memberCount", memberCount), + checkRequired("name", name), + checkRequired("slug", slug), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Workspace = apply { + if (validated) { + return@apply + } + + id() + dateCreated() + memberCount() + name() + slug() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenlayerInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (dateCreated.asKnown().isPresent) 1 else 0) + + (if (memberCount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (slug.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Workspace && + id == other.id && + dateCreated == other.dateCreated && + memberCount == other.memberCount && + name == other.name && + slug == other.slug && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, dateCreated, memberCount, name, slug, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Workspace{id=$id, dateCreated=$dateCreated, memberCount=$memberCount, name=$name, slug=$slug, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + id == other.id && + creator == other.creator && + dateCreated == other.dateCreated && + email == other.email && + role == other.role && + status == other.status && + workspace == other.workspace && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + creator, + dateCreated, + email, + role, + status, + workspace, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, creator=$creator, dateCreated=$dateCreated, email=$email, role=$role, status=$status, workspace=$workspace, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InviteListResponse && + _meta == other._meta && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(_meta, items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InviteListResponse{_meta=$_meta, items=$items, additionalProperties=$additionalProperties}" +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsync.kt new file mode 100644 index 00000000..a768cb11 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsync.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.workspaces.WorkspaceRetrieveParams +import com.openlayer.api.models.workspaces.WorkspaceRetrieveResponse +import com.openlayer.api.models.workspaces.WorkspaceUpdateParams +import com.openlayer.api.models.workspaces.WorkspaceUpdateResponse +import com.openlayer.api.services.async.workspaces.ApiKeyServiceAsync +import com.openlayer.api.services.async.workspaces.InviteServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface WorkspaceServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WorkspaceServiceAsync + + fun invites(): InviteServiceAsync + + fun apiKeys(): ApiKeyServiceAsync + + /** Retrieve a workspace by its ID. */ + fun retrieve(workspaceId: String): CompletableFuture = + retrieve(workspaceId, WorkspaceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + ): CompletableFuture = + retrieve(workspaceId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: WorkspaceRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(workspaceId, WorkspaceRetrieveParams.none(), requestOptions) + + /** Update a workspace. */ + fun update(workspaceId: String): CompletableFuture = + update(workspaceId, WorkspaceUpdateParams.none()) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + ): CompletableFuture = + update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: WorkspaceUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(workspaceId, WorkspaceUpdateParams.none(), requestOptions) + + /** + * A view of [WorkspaceServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): WorkspaceServiceAsync.WithRawResponse + + fun invites(): InviteServiceAsync.WithRawResponse + + fun apiKeys(): ApiKeyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /workspaces/{workspaceId}`, but is otherwise the + * same as [WorkspaceServiceAsync.retrieve]. + */ + fun retrieve( + workspaceId: String + ): CompletableFuture> = + retrieve(workspaceId, WorkspaceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + ): CompletableFuture> = + retrieve(workspaceId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: WorkspaceRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(workspaceId, WorkspaceRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /workspaces/{workspaceId}`, but is otherwise the + * same as [WorkspaceServiceAsync.update]. + */ + fun update( + workspaceId: String + ): CompletableFuture> = + update(workspaceId, WorkspaceUpdateParams.none()) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + ): CompletableFuture> = + update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: WorkspaceUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(workspaceId, WorkspaceUpdateParams.none(), requestOptions) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsyncImpl.kt new file mode 100644 index 00000000..efb8a36e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsyncImpl.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.handlers.errorBodyHandler +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.workspaces.WorkspaceRetrieveParams +import com.openlayer.api.models.workspaces.WorkspaceRetrieveResponse +import com.openlayer.api.models.workspaces.WorkspaceUpdateParams +import com.openlayer.api.models.workspaces.WorkspaceUpdateResponse +import com.openlayer.api.services.async.workspaces.ApiKeyServiceAsync +import com.openlayer.api.services.async.workspaces.ApiKeyServiceAsyncImpl +import com.openlayer.api.services.async.workspaces.InviteServiceAsync +import com.openlayer.api.services.async.workspaces.InviteServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class WorkspaceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceServiceAsync { + + private val withRawResponse: WorkspaceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val invites: InviteServiceAsync by lazy { InviteServiceAsyncImpl(clientOptions) } + + private val apiKeys: ApiKeyServiceAsync by lazy { ApiKeyServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): WorkspaceServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WorkspaceServiceAsync = + WorkspaceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun invites(): InviteServiceAsync = invites + + override fun apiKeys(): ApiKeyServiceAsync = apiKeys + + override fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /workspaces/{workspaceId} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /workspaces/{workspaceId} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val invites: InviteServiceAsync.WithRawResponse by lazy { + InviteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKeys: ApiKeyServiceAsync.WithRawResponse by lazy { + ApiKeyServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): WorkspaceServiceAsync.WithRawResponse = + WorkspaceServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun invites(): InviteServiceAsync.WithRawResponse = invites + + override fun apiKeys(): ApiKeyServiceAsync.WithRawResponse = apiKeys + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsync.kt new file mode 100644 index 00000000..f771bd00 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsync.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.workspaces + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateParams +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ApiKeyServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ApiKeyServiceAsync + + /** Create a new API key in a workspace. */ + fun create(workspaceId: String): CompletableFuture = + create(workspaceId, ApiKeyCreateParams.none()) + + /** @see create */ + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + ): CompletableFuture = create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create(params: ApiKeyCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(workspaceId, ApiKeyCreateParams.none(), requestOptions) + + /** + * A view of [ApiKeyServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ApiKeyServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /workspaces/{workspaceId}/api-keys`, but is + * otherwise the same as [ApiKeyServiceAsync.create]. + */ + fun create(workspaceId: String): CompletableFuture> = + create(workspaceId, ApiKeyCreateParams.none()) + + /** @see create */ + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + ): CompletableFuture> = + create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: ApiKeyCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(workspaceId, ApiKeyCreateParams.none(), requestOptions) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsyncImpl.kt new file mode 100644 index 00000000..4566f11c --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.workspaces + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.handlers.errorBodyHandler +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateParams +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ApiKeyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync { + + private val withRawResponse: ApiKeyServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ApiKeyServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ApiKeyServiceAsync = + ApiKeyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /workspaces/{workspaceId}/api-keys + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ApiKeyServiceAsync.WithRawResponse = + ApiKeyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0), "api-keys") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsync.kt new file mode 100644 index 00000000..fd0b9bfe --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsync.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.workspaces + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.workspaces.invites.InviteCreateParams +import com.openlayer.api.models.workspaces.invites.InviteCreateResponse +import com.openlayer.api.models.workspaces.invites.InviteListParams +import com.openlayer.api.models.workspaces.invites.InviteListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InviteServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InviteServiceAsync + + /** Invite users to a workspace. */ + fun create(workspaceId: String): CompletableFuture = + create(workspaceId, InviteCreateParams.none()) + + /** @see create */ + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + ): CompletableFuture = create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InviteCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create(params: InviteCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + create(workspaceId, InviteCreateParams.none(), requestOptions) + + /** Retrieve a list of invites in a workspace. */ + fun list(workspaceId: String): CompletableFuture = + list(workspaceId, InviteListParams.none()) + + /** @see list */ + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see list */ + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + ): CompletableFuture = list(workspaceId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: InviteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list(params: InviteListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(workspaceId, InviteListParams.none(), requestOptions) + + /** + * A view of [InviteServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InviteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /workspaces/{workspaceId}/invites`, but is + * otherwise the same as [InviteServiceAsync.create]. + */ + fun create(workspaceId: String): CompletableFuture> = + create(workspaceId, InviteCreateParams.none()) + + /** @see create */ + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + ): CompletableFuture> = + create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InviteCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: InviteCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + create(workspaceId, InviteCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /workspaces/{workspaceId}/invites`, but is otherwise + * the same as [InviteServiceAsync.list]. + */ + fun list(workspaceId: String): CompletableFuture> = + list(workspaceId, InviteListParams.none()) + + /** @see list */ + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see list */ + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + ): CompletableFuture> = + list(workspaceId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: InviteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list(params: InviteListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + workspaceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(workspaceId, InviteListParams.none(), requestOptions) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsyncImpl.kt new file mode 100644 index 00000000..9c0584bd --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsyncImpl.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.workspaces + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.handlers.errorBodyHandler +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepareAsync +import com.openlayer.api.models.workspaces.invites.InviteCreateParams +import com.openlayer.api.models.workspaces.invites.InviteCreateResponse +import com.openlayer.api.models.workspaces.invites.InviteListParams +import com.openlayer.api.models.workspaces.invites.InviteListResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InviteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InviteServiceAsync { + + private val withRawResponse: InviteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InviteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InviteServiceAsync = + InviteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: InviteCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /workspaces/{workspaceId}/invites + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: InviteListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /workspaces/{workspaceId}/invites + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InviteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InviteServiceAsync.WithRawResponse = + InviteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: InviteCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0), "invites") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: InviteListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0), "invites") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/WorkspaceService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/WorkspaceService.kt new file mode 100644 index 00000000..d7d48503 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/WorkspaceService.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.workspaces.WorkspaceRetrieveParams +import com.openlayer.api.models.workspaces.WorkspaceRetrieveResponse +import com.openlayer.api.models.workspaces.WorkspaceUpdateParams +import com.openlayer.api.models.workspaces.WorkspaceUpdateResponse +import com.openlayer.api.services.blocking.workspaces.ApiKeyService +import com.openlayer.api.services.blocking.workspaces.InviteService +import java.util.function.Consumer + +interface WorkspaceService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WorkspaceService + + fun invites(): InviteService + + fun apiKeys(): ApiKeyService + + /** Retrieve a workspace by its ID. */ + fun retrieve(workspaceId: String): WorkspaceRetrieveResponse = + retrieve(workspaceId, WorkspaceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): WorkspaceRetrieveResponse = + retrieve(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + ): WorkspaceRetrieveResponse = retrieve(workspaceId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WorkspaceRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: WorkspaceRetrieveParams): WorkspaceRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(workspaceId: String, requestOptions: RequestOptions): WorkspaceRetrieveResponse = + retrieve(workspaceId, WorkspaceRetrieveParams.none(), requestOptions) + + /** Update a workspace. */ + fun update(workspaceId: String): WorkspaceUpdateResponse = + update(workspaceId, WorkspaceUpdateParams.none()) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): WorkspaceUpdateResponse = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + ): WorkspaceUpdateResponse = update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WorkspaceUpdateResponse + + /** @see update */ + fun update(params: WorkspaceUpdateParams): WorkspaceUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(workspaceId: String, requestOptions: RequestOptions): WorkspaceUpdateResponse = + update(workspaceId, WorkspaceUpdateParams.none(), requestOptions) + + /** A view of [WorkspaceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WorkspaceService.WithRawResponse + + fun invites(): InviteService.WithRawResponse + + fun apiKeys(): ApiKeyService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /workspaces/{workspaceId}`, but is otherwise the + * same as [WorkspaceService.retrieve]. + */ + @MustBeClosed + fun retrieve(workspaceId: String): HttpResponseFor = + retrieve(workspaceId, WorkspaceRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + workspaceId: String, + params: WorkspaceRetrieveParams = WorkspaceRetrieveParams.none(), + ): HttpResponseFor = + retrieve(workspaceId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: WorkspaceRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(workspaceId, WorkspaceRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /workspaces/{workspaceId}`, but is otherwise the + * same as [WorkspaceService.update]. + */ + @MustBeClosed + fun update(workspaceId: String): HttpResponseFor = + update(workspaceId, WorkspaceUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + workspaceId: String, + params: WorkspaceUpdateParams = WorkspaceUpdateParams.none(), + ): HttpResponseFor = + update(workspaceId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: WorkspaceUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(workspaceId, WorkspaceUpdateParams.none(), requestOptions) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/WorkspaceServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/WorkspaceServiceImpl.kt new file mode 100644 index 00000000..5a6d6284 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/WorkspaceServiceImpl.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.handlers.errorBodyHandler +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.workspaces.WorkspaceRetrieveParams +import com.openlayer.api.models.workspaces.WorkspaceRetrieveResponse +import com.openlayer.api.models.workspaces.WorkspaceUpdateParams +import com.openlayer.api.models.workspaces.WorkspaceUpdateResponse +import com.openlayer.api.services.blocking.workspaces.ApiKeyService +import com.openlayer.api.services.blocking.workspaces.ApiKeyServiceImpl +import com.openlayer.api.services.blocking.workspaces.InviteService +import com.openlayer.api.services.blocking.workspaces.InviteServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class WorkspaceServiceImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceService { + + private val withRawResponse: WorkspaceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val invites: InviteService by lazy { InviteServiceImpl(clientOptions) } + + private val apiKeys: ApiKeyService by lazy { ApiKeyServiceImpl(clientOptions) } + + override fun withRawResponse(): WorkspaceService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WorkspaceService = + WorkspaceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun invites(): InviteService = invites + + override fun apiKeys(): ApiKeyService = apiKeys + + override fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions, + ): WorkspaceRetrieveResponse = + // get /workspaces/{workspaceId} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): WorkspaceUpdateResponse = + // put /workspaces/{workspaceId} + withRawResponse().update(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WorkspaceService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val invites: InviteService.WithRawResponse by lazy { + InviteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val apiKeys: ApiKeyService.WithRawResponse by lazy { + ApiKeyServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): WorkspaceService.WithRawResponse = + WorkspaceServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun invites(): InviteService.WithRawResponse = invites + + override fun apiKeys(): ApiKeyService.WithRawResponse = apiKeys + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: WorkspaceRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: WorkspaceUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyService.kt new file mode 100644 index 00000000..abc1eea2 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyService.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.workspaces + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateParams +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateResponse +import java.util.function.Consumer + +interface ApiKeyService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ApiKeyService + + /** Create a new API key in a workspace. */ + fun create(workspaceId: String): ApiKeyCreateResponse = + create(workspaceId, ApiKeyCreateParams.none()) + + /** @see create */ + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + ): ApiKeyCreateResponse = create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ApiKeyCreateResponse + + /** @see create */ + fun create(params: ApiKeyCreateParams): ApiKeyCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(workspaceId: String, requestOptions: RequestOptions): ApiKeyCreateResponse = + create(workspaceId, ApiKeyCreateParams.none(), requestOptions) + + /** A view of [ApiKeyService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ApiKeyService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /workspaces/{workspaceId}/api-keys`, but is + * otherwise the same as [ApiKeyService.create]. + */ + @MustBeClosed + fun create(workspaceId: String): HttpResponseFor = + create(workspaceId, ApiKeyCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + workspaceId: String, + params: ApiKeyCreateParams = ApiKeyCreateParams.none(), + ): HttpResponseFor = + create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create(params: ApiKeyCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(workspaceId, ApiKeyCreateParams.none(), requestOptions) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyServiceImpl.kt new file mode 100644 index 00000000..70936566 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyServiceImpl.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.workspaces + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.handlers.errorBodyHandler +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateParams +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ApiKeyServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService { + + private val withRawResponse: ApiKeyService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ApiKeyService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ApiKeyService = + ApiKeyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): ApiKeyCreateResponse = + // post /workspaces/{workspaceId}/api-keys + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ApiKeyService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ApiKeyService.WithRawResponse = + ApiKeyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ApiKeyCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0), "api-keys") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/InviteService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/InviteService.kt new file mode 100644 index 00000000..813cdb6f --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/InviteService.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.workspaces + +import com.google.errorprone.annotations.MustBeClosed +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.models.workspaces.invites.InviteCreateParams +import com.openlayer.api.models.workspaces.invites.InviteCreateResponse +import com.openlayer.api.models.workspaces.invites.InviteListParams +import com.openlayer.api.models.workspaces.invites.InviteListResponse +import java.util.function.Consumer + +interface InviteService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InviteService + + /** Invite users to a workspace. */ + fun create(workspaceId: String): InviteCreateResponse = + create(workspaceId, InviteCreateParams.none()) + + /** @see create */ + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InviteCreateResponse = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + ): InviteCreateResponse = create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + fun create( + params: InviteCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InviteCreateResponse + + /** @see create */ + fun create(params: InviteCreateParams): InviteCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(workspaceId: String, requestOptions: RequestOptions): InviteCreateResponse = + create(workspaceId, InviteCreateParams.none(), requestOptions) + + /** Retrieve a list of invites in a workspace. */ + fun list(workspaceId: String): InviteListResponse = list(workspaceId, InviteListParams.none()) + + /** @see list */ + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): InviteListResponse = + list(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see list */ + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + ): InviteListResponse = list(workspaceId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: InviteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InviteListResponse + + /** @see list */ + fun list(params: InviteListParams): InviteListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(workspaceId: String, requestOptions: RequestOptions): InviteListResponse = + list(workspaceId, InviteListParams.none(), requestOptions) + + /** A view of [InviteService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InviteService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /workspaces/{workspaceId}/invites`, but is + * otherwise the same as [InviteService.create]. + */ + @MustBeClosed + fun create(workspaceId: String): HttpResponseFor = + create(workspaceId, InviteCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create( + workspaceId: String, + params: InviteCreateParams = InviteCreateParams.none(), + ): HttpResponseFor = + create(workspaceId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: InviteCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create(params: InviteCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + create(workspaceId, InviteCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /workspaces/{workspaceId}/invites`, but is otherwise + * the same as [InviteService.list]. + */ + @MustBeClosed + fun list(workspaceId: String): HttpResponseFor = + list(workspaceId, InviteListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().workspaceId(workspaceId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + workspaceId: String, + params: InviteListParams = InviteListParams.none(), + ): HttpResponseFor = list(workspaceId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: InviteListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: InviteListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + workspaceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(workspaceId, InviteListParams.none(), requestOptions) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/InviteServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/InviteServiceImpl.kt new file mode 100644 index 00000000..f513c8cb --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/workspaces/InviteServiceImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.workspaces + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.checkRequired +import com.openlayer.api.core.handlers.errorBodyHandler +import com.openlayer.api.core.handlers.errorHandler +import com.openlayer.api.core.handlers.jsonHandler +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.core.http.HttpResponseFor +import com.openlayer.api.core.http.json +import com.openlayer.api.core.http.parseable +import com.openlayer.api.core.prepare +import com.openlayer.api.models.workspaces.invites.InviteCreateParams +import com.openlayer.api.models.workspaces.invites.InviteCreateResponse +import com.openlayer.api.models.workspaces.invites.InviteListParams +import com.openlayer.api.models.workspaces.invites.InviteListResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class InviteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InviteService { + + private val withRawResponse: InviteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InviteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InviteService = + InviteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: InviteCreateParams, + requestOptions: RequestOptions, + ): InviteCreateResponse = + // post /workspaces/{workspaceId}/invites + withRawResponse().create(params, requestOptions).parse() + + override fun list( + params: InviteListParams, + requestOptions: RequestOptions, + ): InviteListResponse = + // get /workspaces/{workspaceId}/invites + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InviteService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InviteService.WithRawResponse = + InviteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: InviteCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0), "invites") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: InviteListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("workspaceId", params.workspaceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("workspaces", params._pathParam(0), "invites") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveParamsTest.kt new file mode 100644 index 00000000..4c61b8c6 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceRetrieveParamsTest { + + @Test + fun create() { + WorkspaceRetrieveParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + WorkspaceRetrieveParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveResponseTest.kt new file mode 100644 index 00000000..3bd2fde4 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceRetrieveResponseTest.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceRetrieveResponseTest { + + @Test + fun create() { + val workspaceRetrieveResponse = + WorkspaceRetrieveResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(WorkspaceRetrieveResponse.Status.ACTIVE) + .addMonthlyUsage( + WorkspaceRetrieveResponse.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + + assertThat(workspaceRetrieveResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(workspaceRetrieveResponse.creatorId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(workspaceRetrieveResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceRetrieveResponse.dateUpdated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceRetrieveResponse.inviteCount()).isEqualTo(0L) + assertThat(workspaceRetrieveResponse.memberCount()).isEqualTo(0L) + assertThat(workspaceRetrieveResponse.name()).isEqualTo("Openlayer") + assertThat(workspaceRetrieveResponse.periodEndDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceRetrieveResponse.periodStartDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceRetrieveResponse.projectCount()).isEqualTo(0L) + assertThat(workspaceRetrieveResponse.slug()).isEqualTo("openlayer") + assertThat(workspaceRetrieveResponse.status()) + .isEqualTo(WorkspaceRetrieveResponse.Status.ACTIVE) + assertThat(workspaceRetrieveResponse.monthlyUsage().getOrNull()) + .containsExactly( + WorkspaceRetrieveResponse.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + assertThat(workspaceRetrieveResponse.samlOnlyAccess()).contains(true) + assertThat(workspaceRetrieveResponse.wildcardDomains().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val workspaceRetrieveResponse = + WorkspaceRetrieveResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(WorkspaceRetrieveResponse.Status.ACTIVE) + .addMonthlyUsage( + WorkspaceRetrieveResponse.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + + val roundtrippedWorkspaceRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(workspaceRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWorkspaceRetrieveResponse).isEqualTo(workspaceRetrieveResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateParamsTest.kt new file mode 100644 index 00000000..541daea8 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateParamsTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceUpdateParamsTest { + + @Test + fun create() { + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inviteCode("inviteCode") + .name("Openlayer") + .slug("openlayer") + .build() + } + + @Test + fun pathParams() { + val params = + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inviteCode("inviteCode") + .name("Openlayer") + .slug("openlayer") + .build() + + val body = params._body() + + assertThat(body.inviteCode()).contains("inviteCode") + assertThat(body.name()).contains("Openlayer") + assertThat(body.slug()).contains("openlayer") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val body = params._body() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateResponseTest.kt new file mode 100644 index 00000000..321b0406 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/WorkspaceUpdateResponseTest.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WorkspaceUpdateResponseTest { + + @Test + fun create() { + val workspaceUpdateResponse = + WorkspaceUpdateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(WorkspaceUpdateResponse.Status.ACTIVE) + .addMonthlyUsage( + WorkspaceUpdateResponse.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + + assertThat(workspaceUpdateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(workspaceUpdateResponse.creatorId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(workspaceUpdateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceUpdateResponse.dateUpdated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceUpdateResponse.inviteCount()).isEqualTo(0L) + assertThat(workspaceUpdateResponse.memberCount()).isEqualTo(0L) + assertThat(workspaceUpdateResponse.name()).isEqualTo("Openlayer") + assertThat(workspaceUpdateResponse.periodEndDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceUpdateResponse.periodStartDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(workspaceUpdateResponse.projectCount()).isEqualTo(0L) + assertThat(workspaceUpdateResponse.slug()).isEqualTo("openlayer") + assertThat(workspaceUpdateResponse.status()) + .isEqualTo(WorkspaceUpdateResponse.Status.ACTIVE) + assertThat(workspaceUpdateResponse.monthlyUsage().getOrNull()) + .containsExactly( + WorkspaceUpdateResponse.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + assertThat(workspaceUpdateResponse.samlOnlyAccess()).contains(true) + assertThat(workspaceUpdateResponse.wildcardDomains().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val workspaceUpdateResponse = + WorkspaceUpdateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creatorId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .inviteCount(0L) + .memberCount(0L) + .name("Openlayer") + .periodEndDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .periodStartDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .projectCount(0L) + .slug("openlayer") + .status(WorkspaceUpdateResponse.Status.ACTIVE) + .addMonthlyUsage( + WorkspaceUpdateResponse.MonthlyUsage.builder() + .executionTimeMs(0L) + .monthYear(LocalDate.parse("2019-12-27")) + .predictionCount(0L) + .build() + ) + .samlOnlyAccess(true) + .addWildcardDomain("string") + .build() + + val roundtrippedWorkspaceUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(workspaceUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWorkspaceUpdateResponse).isEqualTo(workspaceUpdateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateParamsTest.kt new file mode 100644 index 00000000..6a30e296 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.apikeys + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyCreateParamsTest { + + @Test + fun create() { + ApiKeyCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Secret Key") + .build() + } + + @Test + fun pathParams() { + val params = + ApiKeyCreateParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ApiKeyCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Secret Key") + .build() + + val body = params._body() + + assertThat(body.name()).contains("Secret Key") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ApiKeyCreateParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateResponseTest.kt new file mode 100644 index 00000000..c6313a20 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/apikeys/ApiKeyCreateResponseTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.apikeys + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApiKeyCreateResponseTest { + + @Test + fun create() { + val apiKeyCreateResponse = + ApiKeyCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateLastUsed(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .secureKey("sk-ol-*************************5PW0") + .name("Secret Key") + .build() + + assertThat(apiKeyCreateResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(apiKeyCreateResponse.dateCreated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.dateLastUsed()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.dateUpdated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(apiKeyCreateResponse.secureKey()) + .isEqualTo("sk-ol-*************************5PW0") + assertThat(apiKeyCreateResponse.name()).contains("Secret Key") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val apiKeyCreateResponse = + ApiKeyCreateResponse.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateLastUsed(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dateUpdated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .secureKey("sk-ol-*************************5PW0") + .name("Secret Key") + .build() + + val roundtrippedApiKeyCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(apiKeyCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedApiKeyCreateResponse).isEqualTo(apiKeyCreateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateParamsTest.kt new file mode 100644 index 00000000..b1362c8a --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InviteCreateParamsTest { + + @Test + fun create() { + InviteCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEmail("user@email.com") + .role(InviteCreateParams.Role.ADMIN) + .build() + } + + @Test + fun pathParams() { + val params = + InviteCreateParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + InviteCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEmail("user@email.com") + .role(InviteCreateParams.Role.ADMIN) + .build() + + val body = params._body() + + assertThat(body.emails().getOrNull()).containsExactly("user@email.com") + assertThat(body.role()).contains(InviteCreateParams.Role.ADMIN) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InviteCreateParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val body = params._body() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateResponseTest.kt new file mode 100644 index 00000000..dd2c0c63 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteCreateResponseTest.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InviteCreateResponseTest { + + @Test + fun create() { + val inviteCreateResponse = + InviteCreateResponse.builder() + .addItem( + InviteCreateResponse.Item.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creator( + InviteCreateResponse.Item.Creator.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Rishab Ramanathan") + .username("user123") + .build() + ) + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("user@email.com") + .role(InviteCreateResponse.Item.Role.ADMIN) + .status(InviteCreateResponse.Item.Status.ACCEPTED) + .workspace( + InviteCreateResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memberCount(0L) + .name("Openlayer") + .slug("openlayer") + .build() + ) + .build() + ) + .build() + + assertThat(inviteCreateResponse.items()) + .containsExactly( + InviteCreateResponse.Item.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creator( + InviteCreateResponse.Item.Creator.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Rishab Ramanathan") + .username("user123") + .build() + ) + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("user@email.com") + .role(InviteCreateResponse.Item.Role.ADMIN) + .status(InviteCreateResponse.Item.Status.ACCEPTED) + .workspace( + InviteCreateResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memberCount(0L) + .name("Openlayer") + .slug("openlayer") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inviteCreateResponse = + InviteCreateResponse.builder() + .addItem( + InviteCreateResponse.Item.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creator( + InviteCreateResponse.Item.Creator.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Rishab Ramanathan") + .username("user123") + .build() + ) + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("user@email.com") + .role(InviteCreateResponse.Item.Role.ADMIN) + .status(InviteCreateResponse.Item.Status.ACCEPTED) + .workspace( + InviteCreateResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memberCount(0L) + .name("Openlayer") + .slug("openlayer") + .build() + ) + .build() + ) + .build() + + val roundtrippedInviteCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inviteCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInviteCreateResponse).isEqualTo(inviteCreateResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteListParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteListParamsTest.kt new file mode 100644 index 00000000..579ddc0d --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteListParamsTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +import com.openlayer.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InviteListParamsTest { + + @Test + fun create() { + InviteListParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + } + + @Test + fun pathParams() { + val params = + InviteListParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + InviteListParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("page", "1").put("perPage", "1").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + InviteListParams.builder().workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteListResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteListResponseTest.kt new file mode 100644 index 00000000..97e08b7f --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/workspaces/invites/InviteListResponseTest.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models.workspaces.invites + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openlayer.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InviteListResponseTest { + + @Test + fun create() { + val inviteListResponse = + InviteListResponse.builder() + ._meta( + InviteListResponse._Meta + .builder() + .page(1L) + .perPage(1L) + .totalItems(0L) + .totalPages(0L) + .build() + ) + .addItem( + InviteListResponse.Item.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creator( + InviteListResponse.Item.Creator.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Rishab Ramanathan") + .username("user123") + .build() + ) + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("user@email.com") + .role(InviteListResponse.Item.Role.ADMIN) + .status(InviteListResponse.Item.Status.ACCEPTED) + .workspace( + InviteListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memberCount(0L) + .name("Openlayer") + .slug("openlayer") + .build() + ) + .build() + ) + .build() + + assertThat(inviteListResponse._meta()) + .isEqualTo( + InviteListResponse._Meta + .builder() + .page(1L) + .perPage(1L) + .totalItems(0L) + .totalPages(0L) + .build() + ) + assertThat(inviteListResponse.items()) + .containsExactly( + InviteListResponse.Item.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creator( + InviteListResponse.Item.Creator.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Rishab Ramanathan") + .username("user123") + .build() + ) + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("user@email.com") + .role(InviteListResponse.Item.Role.ADMIN) + .status(InviteListResponse.Item.Status.ACCEPTED) + .workspace( + InviteListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memberCount(0L) + .name("Openlayer") + .slug("openlayer") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inviteListResponse = + InviteListResponse.builder() + ._meta( + InviteListResponse._Meta + .builder() + .page(1L) + .perPage(1L) + .totalItems(0L) + .totalPages(0L) + .build() + ) + .addItem( + InviteListResponse.Item.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .creator( + InviteListResponse.Item.Creator.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Rishab Ramanathan") + .username("user123") + .build() + ) + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("user@email.com") + .role(InviteListResponse.Item.Role.ADMIN) + .status(InviteListResponse.Item.Status.ACCEPTED) + .workspace( + InviteListResponse.Item.Workspace.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dateCreated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .memberCount(0L) + .name("Openlayer") + .slug("openlayer") + .build() + ) + .build() + ) + .build() + + val roundtrippedInviteListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inviteListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInviteListResponse).isEqualTo(inviteListResponse) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsyncTest.kt new file mode 100644 index 00000000..3cd067b2 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/WorkspaceServiceAsyncTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.workspaces.WorkspaceUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class WorkspaceServiceAsyncTest { + + @Test + fun retrieve() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val workspaceServiceAsync = client.workspaces() + + val workspaceFuture = workspaceServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val workspace = workspaceFuture.get() + workspace.validate() + } + + @Test + fun update() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val workspaceServiceAsync = client.workspaces() + + val workspaceFuture = + workspaceServiceAsync.update( + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inviteCode("inviteCode") + .name("Openlayer") + .slug("openlayer") + .build() + ) + + val workspace = workspaceFuture.get() + workspace.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsyncTest.kt new file mode 100644 index 00000000..c58cc3db --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/workspaces/ApiKeyServiceAsyncTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.workspaces + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ApiKeyServiceAsyncTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyServiceAsync = client.workspaces().apiKeys() + + val apiKeyFuture = + apiKeyServiceAsync.create( + ApiKeyCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Secret Key") + .build() + ) + + val apiKey = apiKeyFuture.get() + apiKey.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsyncTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsyncTest.kt new file mode 100644 index 00000000..2c8f2998 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/async/workspaces/InviteServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.workspaces + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClientAsync +import com.openlayer.api.models.workspaces.invites.InviteCreateParams +import com.openlayer.api.models.workspaces.invites.InviteListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InviteServiceAsyncTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inviteServiceAsync = client.workspaces().invites() + + val inviteFuture = + inviteServiceAsync.create( + InviteCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEmail("user@email.com") + .role(InviteCreateParams.Role.ADMIN) + .build() + ) + + val invite = inviteFuture.get() + invite.validate() + } + + @Test + fun list() { + val client = + OpenlayerOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inviteServiceAsync = client.workspaces().invites() + + val invitesFuture = + inviteServiceAsync.list( + InviteListParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + ) + + val invites = invitesFuture.get() + invites.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/WorkspaceServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/WorkspaceServiceTest.kt new file mode 100644 index 00000000..5a548cdd --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/WorkspaceServiceTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient +import com.openlayer.api.models.workspaces.WorkspaceUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class WorkspaceServiceTest { + + @Test + fun retrieve() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val workspaceService = client.workspaces() + + val workspace = workspaceService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + workspace.validate() + } + + @Test + fun update() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val workspaceService = client.workspaces() + + val workspace = + workspaceService.update( + WorkspaceUpdateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .inviteCode("inviteCode") + .name("Openlayer") + .slug("openlayer") + .build() + ) + + workspace.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyServiceTest.kt new file mode 100644 index 00000000..f4e1506b --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/workspaces/ApiKeyServiceTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.workspaces + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient +import com.openlayer.api.models.workspaces.apikeys.ApiKeyCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ApiKeyServiceTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val apiKeyService = client.workspaces().apiKeys() + + val apiKey = + apiKeyService.create( + ApiKeyCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("Secret Key") + .build() + ) + + apiKey.validate() + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/workspaces/InviteServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/workspaces/InviteServiceTest.kt new file mode 100644 index 00000000..bbacf4aa --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/workspaces/InviteServiceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.workspaces + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient +import com.openlayer.api.models.workspaces.invites.InviteCreateParams +import com.openlayer.api.models.workspaces.invites.InviteListParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InviteServiceTest { + + @Test + fun create() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inviteService = client.workspaces().invites() + + val invite = + inviteService.create( + InviteCreateParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEmail("user@email.com") + .role(InviteCreateParams.Role.ADMIN) + .build() + ) + + invite.validate() + } + + @Test + fun list() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inviteService = client.workspaces().invites() + + val invites = + inviteService.list( + InviteListParams.builder() + .workspaceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .page(1L) + .perPage(1L) + .build() + ) + + invites.validate() + } +} diff --git a/openlayer-java-proguard-test/src/test/kotlin/com/openlayer/api/proguard/ProGuardCompatibilityTest.kt b/openlayer-java-proguard-test/src/test/kotlin/com/openlayer/api/proguard/ProGuardCompatibilityTest.kt index 0a51ea22..394091b7 100644 --- a/openlayer-java-proguard-test/src/test/kotlin/com/openlayer/api/proguard/ProGuardCompatibilityTest.kt +++ b/openlayer-java-proguard-test/src/test/kotlin/com/openlayer/api/proguard/ProGuardCompatibilityTest.kt @@ -48,6 +48,7 @@ internal class ProGuardCompatibilityTest { assertThat(client).isNotNull() assertThat(client.projects()).isNotNull() + assertThat(client.workspaces()).isNotNull() assertThat(client.commits()).isNotNull() assertThat(client.inferencePipelines()).isNotNull() assertThat(client.storage()).isNotNull()