From 6a1a02b54a87dc5ad846086f4ca0eda047928720 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 02:54:32 +0000 Subject: [PATCH 1/5] docs: update comment --- .../chat/completions/ChatCompletionListParams.kt | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt index 0d426829..302f3fa3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt @@ -35,12 +35,9 @@ private constructor( fun limit(): Optional = Optional.ofNullable(limit) /** - * Set of 16 key-value pairs that can be attached to an object. This can be useful for storing - * additional information about the object in a structured format, and querying for objects via - * API or the dashboard. + * A list of metadata keys to filter the Chat Completions by. Example: * - * Keys are strings with a maximum length of 64 characters. Values are strings with a maximum - * length of 512 characters. + * `metadata[key1]=value1&metadata[key2]=value2` */ fun metadata(): Optional = Optional.ofNullable(metadata) @@ -111,12 +108,9 @@ private constructor( fun limit(limit: Optional) = limit(limit.getOrNull()) /** - * Set of 16 key-value pairs that can be attached to an object. This can be useful for - * storing additional information about the object in a structured format, and querying for - * objects via API or the dashboard. + * A list of metadata keys to filter the Chat Completions by. Example: * - * Keys are strings with a maximum length of 64 characters. Values are strings with a - * maximum length of 512 characters. + * `metadata[key1]=value1&metadata[key2]=value2` */ fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } From c590a943a4adf55d77bac25ae68bce0eaa84b24c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 20:45:23 +0000 Subject: [PATCH 2/5] codegen metadata --- .stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.stats.yml b/.stats.yml index 03d2cca2..910405a9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 147 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-47ef7e0aaa2f2052404041650c9b4d7d8c9c51c45ef2cb081548f329c3f81a6a.yml -openapi_spec_hash: 0207b30cf74121a12c1647e25463cee9 -config_hash: 8dca0f2dc2706c07cf2f8d0ed4dc062e +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-1595c7e4e1d7bf7eae2e49ad800316e13b69ffb18bff2a2f55236fce792deb53.yml +openapi_spec_hash: c3a3a0d8d4bbf11179149244f017a6dc +config_hash: f6cdeee28c96db61b0a5d92e414bc0ae From 7ba687d3968bcdeec47a890bc9003abe3cd24f09 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 22:05:35 +0000 Subject: [PATCH 3/5] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 910405a9..5a4cf71a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 147 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-1595c7e4e1d7bf7eae2e49ad800316e13b69ffb18bff2a2f55236fce792deb53.yml openapi_spec_hash: c3a3a0d8d4bbf11179149244f017a6dc -config_hash: f6cdeee28c96db61b0a5d92e414bc0ae +config_hash: 948733484caf41e71093c6582dbc319c From c248c522e1ef826aa28c1176dee234ba64bc0550 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 19:13:10 +0000 Subject: [PATCH 4/5] feat(api): container network_policy and skills --- .stats.yml | 4 +- .../containers/ContainerCreateParams.kt | 613 +++++++++++++++++- .../containers/ContainerCreateResponse.kt | 396 ++++++++++- .../models/containers/ContainerListParams.kt | 19 +- .../containers/ContainerListResponse.kt | 396 ++++++++++- .../containers/ContainerRetrieveResponse.kt | 396 ++++++++++- .../containers/ContainerCreateParamsTest.kt | 18 + .../containers/ContainerCreateResponseTest.kt | 19 + .../ContainerListPageResponseTest.kt | 18 + .../containers/ContainerListParamsTest.kt | 3 + .../containers/ContainerListResponseTest.kt | 19 + .../ContainerRetrieveResponseTest.kt | 19 + .../async/ContainerServiceAsyncTest.kt | 4 + .../services/blocking/ContainerServiceTest.kt | 4 + 14 files changed, 1914 insertions(+), 14 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5a4cf71a..2eb104c3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 147 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-1595c7e4e1d7bf7eae2e49ad800316e13b69ffb18bff2a2f55236fce792deb53.yml -openapi_spec_hash: c3a3a0d8d4bbf11179149244f017a6dc +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-0db5326a0fb6a30ffad9242c72872c3388ef927e8a4549ddd20aec3420541209.yml +openapi_spec_hash: 9523fe30739802e15c88f4e7aac44e7f config_hash: 948733484caf41e71093c6582dbc319c diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt index 49dfcf01..9cfad313 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt @@ -6,6 +6,15 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer import com.openai.core.Enum import com.openai.core.ExcludeMissing import com.openai.core.JsonField @@ -14,10 +23,15 @@ import com.openai.core.JsonValue import com.openai.core.Params import com.openai.core.checkKnown import com.openai.core.checkRequired +import com.openai.core.getOrThrow import com.openai.core.http.Headers import com.openai.core.http.QueryParams import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException +import com.openai.models.responses.ContainerNetworkPolicyAllowlist +import com.openai.models.responses.ContainerNetworkPolicyDisabled +import com.openai.models.responses.InlineSkill +import com.openai.models.responses.SkillReference import java.util.Collections import java.util.Objects import java.util.Optional @@ -63,6 +77,22 @@ private constructor( */ fun memoryLimit(): Optional = body.memoryLimit() + /** + * Network access policy for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkPolicy(): Optional = body.networkPolicy() + + /** + * An optional list of skills referenced by id or inline data. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skills(): Optional> = body.skills() + /** * Returns the raw JSON value of [name]. * @@ -91,6 +121,20 @@ private constructor( */ fun _memoryLimit(): JsonField = body._memoryLimit() + /** + * Returns the raw JSON value of [networkPolicy]. + * + * Unlike [networkPolicy], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _networkPolicy(): JsonField = body._networkPolicy() + + /** + * Returns the raw JSON value of [skills]. + * + * Unlike [skills], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _skills(): JsonField> = body._skills() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -137,6 +181,8 @@ private constructor( * - [expiresAfter] * - [fileIds] * - [memoryLimit] + * - [networkPolicy] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -198,6 +244,79 @@ private constructor( body.memoryLimit(memoryLimit) } + /** Network access policy for the container. */ + fun networkPolicy(networkPolicy: NetworkPolicy) = apply { + body.networkPolicy(networkPolicy) + } + + /** + * Sets [Builder.networkPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.networkPolicy] with a well-typed [NetworkPolicy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkPolicy(networkPolicy: JsonField) = apply { + body.networkPolicy(networkPolicy) + } + + /** Alias for calling [networkPolicy] with `NetworkPolicy.ofDisabled(disabled)`. */ + fun networkPolicy(disabled: ContainerNetworkPolicyDisabled) = apply { + body.networkPolicy(disabled) + } + + /** Alias for calling [networkPolicy] with `NetworkPolicy.ofAllowlist(allowlist)`. */ + fun networkPolicy(allowlist: ContainerNetworkPolicyAllowlist) = apply { + body.networkPolicy(allowlist) + } + + /** + * Alias for calling [networkPolicy] with the following: + * ```java + * ContainerNetworkPolicyAllowlist.builder() + * .allowedDomains(allowedDomains) + * .build() + * ``` + */ + fun allowlistNetworkPolicy(allowedDomains: List) = apply { + body.allowlistNetworkPolicy(allowedDomains) + } + + /** An optional list of skills referenced by id or inline data. */ + fun skills(skills: List) = apply { body.skills(skills) } + + /** + * Sets [Builder.skills] to an arbitrary JSON value. + * + * You should usually call [Builder.skills] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun skills(skills: JsonField>) = apply { body.skills(skills) } + + /** + * Adds a single [Skill] to [skills]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSkill(skill: Skill) = apply { body.addSkill(skill) } + + /** Alias for calling [addSkill] with `Skill.ofReference(reference)`. */ + fun addSkill(reference: SkillReference) = apply { body.addSkill(reference) } + + /** + * Alias for calling [addSkill] with the following: + * ```java + * SkillReference.builder() + * .skillId(skillId) + * .build() + * ``` + */ + fun addReferenceSkill(skillId: String) = apply { body.addReferenceSkill(skillId) } + + /** Alias for calling [addSkill] with `Skill.ofInline(inline)`. */ + fun addSkill(inline: InlineSkill) = apply { body.addSkill(inline) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -348,6 +467,8 @@ private constructor( private val expiresAfter: JsonField, private val fileIds: JsonField>, private val memoryLimit: JsonField, + private val networkPolicy: JsonField, + private val skills: JsonField>, private val additionalProperties: MutableMap, ) { @@ -363,7 +484,13 @@ private constructor( @JsonProperty("memory_limit") @ExcludeMissing memoryLimit: JsonField = JsonMissing.of(), - ) : this(name, expiresAfter, fileIds, memoryLimit, mutableMapOf()) + @JsonProperty("network_policy") + @ExcludeMissing + networkPolicy: JsonField = JsonMissing.of(), + @JsonProperty("skills") + @ExcludeMissing + skills: JsonField> = JsonMissing.of(), + ) : this(name, expiresAfter, fileIds, memoryLimit, networkPolicy, skills, mutableMapOf()) /** * Name of the container to create. @@ -397,6 +524,22 @@ private constructor( */ fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** + * Network access policy for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkPolicy(): Optional = networkPolicy.getOptional("network_policy") + + /** + * An optional list of skills referenced by id or inline data. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun skills(): Optional> = skills.getOptional("skills") + /** * Returns the raw JSON value of [name]. * @@ -430,6 +573,23 @@ private constructor( @ExcludeMissing fun _memoryLimit(): JsonField = memoryLimit + /** + * Returns the raw JSON value of [networkPolicy]. + * + * Unlike [networkPolicy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_policy") + @ExcludeMissing + fun _networkPolicy(): JsonField = networkPolicy + + /** + * Returns the raw JSON value of [skills]. + * + * Unlike [skills], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("skills") @ExcludeMissing fun _skills(): JsonField> = skills + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -462,6 +622,8 @@ private constructor( private var expiresAfter: JsonField = JsonMissing.of() private var fileIds: JsonField>? = null private var memoryLimit: JsonField = JsonMissing.of() + private var networkPolicy: JsonField = JsonMissing.of() + private var skills: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -470,6 +632,8 @@ private constructor( expiresAfter = body.expiresAfter fileIds = body.fileIds.map { it.toMutableList() } memoryLimit = body.memoryLimit + networkPolicy = body.networkPolicy + skills = body.skills.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -539,6 +703,85 @@ private constructor( this.memoryLimit = memoryLimit } + /** Network access policy for the container. */ + fun networkPolicy(networkPolicy: NetworkPolicy) = + networkPolicy(JsonField.of(networkPolicy)) + + /** + * Sets [Builder.networkPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.networkPolicy] with a well-typed [NetworkPolicy] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun networkPolicy(networkPolicy: JsonField) = apply { + this.networkPolicy = networkPolicy + } + + /** Alias for calling [networkPolicy] with `NetworkPolicy.ofDisabled(disabled)`. */ + fun networkPolicy(disabled: ContainerNetworkPolicyDisabled) = + networkPolicy(NetworkPolicy.ofDisabled(disabled)) + + /** Alias for calling [networkPolicy] with `NetworkPolicy.ofAllowlist(allowlist)`. */ + fun networkPolicy(allowlist: ContainerNetworkPolicyAllowlist) = + networkPolicy(NetworkPolicy.ofAllowlist(allowlist)) + + /** + * Alias for calling [networkPolicy] with the following: + * ```java + * ContainerNetworkPolicyAllowlist.builder() + * .allowedDomains(allowedDomains) + * .build() + * ``` + */ + fun allowlistNetworkPolicy(allowedDomains: List) = + networkPolicy( + ContainerNetworkPolicyAllowlist.builder().allowedDomains(allowedDomains).build() + ) + + /** An optional list of skills referenced by id or inline data. */ + fun skills(skills: List) = skills(JsonField.of(skills)) + + /** + * Sets [Builder.skills] to an arbitrary JSON value. + * + * You should usually call [Builder.skills] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun skills(skills: JsonField>) = apply { + this.skills = skills.map { it.toMutableList() } + } + + /** + * Adds a single [Skill] to [skills]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSkill(skill: Skill) = apply { + skills = + (skills ?: JsonField.of(mutableListOf())).also { + checkKnown("skills", it).add(skill) + } + } + + /** Alias for calling [addSkill] with `Skill.ofReference(reference)`. */ + fun addSkill(reference: SkillReference) = addSkill(Skill.ofReference(reference)) + + /** + * Alias for calling [addSkill] with the following: + * ```java + * SkillReference.builder() + * .skillId(skillId) + * .build() + * ``` + */ + fun addReferenceSkill(skillId: String) = + addSkill(SkillReference.builder().skillId(skillId).build()) + + /** Alias for calling [addSkill] with `Skill.ofInline(inline)`. */ + fun addSkill(inline: InlineSkill) = addSkill(Skill.ofInline(inline)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -576,6 +819,8 @@ private constructor( expiresAfter, (fileIds ?: JsonMissing.of()).map { it.toImmutable() }, memoryLimit, + networkPolicy, + (skills ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -591,6 +836,8 @@ private constructor( expiresAfter().ifPresent { it.validate() } fileIds() memoryLimit().ifPresent { it.validate() } + networkPolicy().ifPresent { it.validate() } + skills().ifPresent { it.forEach { it.validate() } } validated = true } @@ -613,7 +860,9 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (fileIds.asKnown().getOrNull()?.size ?: 0) + - (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + + (networkPolicy.asKnown().getOrNull()?.validity() ?: 0) + + (skills.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -625,17 +874,27 @@ private constructor( expiresAfter == other.expiresAfter && fileIds == other.fileIds && memoryLimit == other.memoryLimit && + networkPolicy == other.networkPolicy && + skills == other.skills && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(name, expiresAfter, fileIds, memoryLimit, additionalProperties) + Objects.hash( + name, + expiresAfter, + fileIds, + memoryLimit, + networkPolicy, + skills, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, expiresAfter=$expiresAfter, fileIds=$fileIds, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" + "Body{name=$name, expiresAfter=$expiresAfter, fileIds=$fileIds, memoryLimit=$memoryLimit, networkPolicy=$networkPolicy, skills=$skills, additionalProperties=$additionalProperties}" } /** Container expiration time in seconds relative to the 'anchor' time. */ @@ -1101,6 +1360,352 @@ private constructor( override fun toString() = value.toString() } + /** Network access policy for the container. */ + @JsonDeserialize(using = NetworkPolicy.Deserializer::class) + @JsonSerialize(using = NetworkPolicy.Serializer::class) + class NetworkPolicy + private constructor( + private val disabled: ContainerNetworkPolicyDisabled? = null, + private val allowlist: ContainerNetworkPolicyAllowlist? = null, + private val _json: JsonValue? = null, + ) { + + fun disabled(): Optional = Optional.ofNullable(disabled) + + fun allowlist(): Optional = Optional.ofNullable(allowlist) + + fun isDisabled(): Boolean = disabled != null + + fun isAllowlist(): Boolean = allowlist != null + + fun asDisabled(): ContainerNetworkPolicyDisabled = disabled.getOrThrow("disabled") + + fun asAllowlist(): ContainerNetworkPolicyAllowlist = allowlist.getOrThrow("allowlist") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + disabled != null -> visitor.visitDisabled(disabled) + allowlist != null -> visitor.visitAllowlist(allowlist) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): NetworkPolicy = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitDisabled(disabled: ContainerNetworkPolicyDisabled) { + disabled.validate() + } + + override fun visitAllowlist(allowlist: ContainerNetworkPolicyAllowlist) { + allowlist.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitDisabled(disabled: ContainerNetworkPolicyDisabled) = + disabled.validity() + + override fun visitAllowlist(allowlist: ContainerNetworkPolicyAllowlist) = + allowlist.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NetworkPolicy && + disabled == other.disabled && + allowlist == other.allowlist + } + + override fun hashCode(): Int = Objects.hash(disabled, allowlist) + + override fun toString(): String = + when { + disabled != null -> "NetworkPolicy{disabled=$disabled}" + allowlist != null -> "NetworkPolicy{allowlist=$allowlist}" + _json != null -> "NetworkPolicy{_unknown=$_json}" + else -> throw IllegalStateException("Invalid NetworkPolicy") + } + + companion object { + + @JvmStatic + fun ofDisabled(disabled: ContainerNetworkPolicyDisabled) = + NetworkPolicy(disabled = disabled) + + @JvmStatic + fun ofAllowlist(allowlist: ContainerNetworkPolicyAllowlist) = + NetworkPolicy(allowlist = allowlist) + } + + /** + * An interface that defines how to map each variant of [NetworkPolicy] to a value of type + * [T]. + */ + interface Visitor { + + fun visitDisabled(disabled: ContainerNetworkPolicyDisabled): T + + fun visitAllowlist(allowlist: ContainerNetworkPolicyAllowlist): T + + /** + * Maps an unknown variant of [NetworkPolicy] to a value of type [T]. + * + * An instance of [NetworkPolicy] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown NetworkPolicy: $json") + } + } + + internal class Deserializer : BaseDeserializer(NetworkPolicy::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): NetworkPolicy { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "disabled" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { NetworkPolicy(disabled = it, _json = json) } + ?: NetworkPolicy(_json = json) + } + "allowlist" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { NetworkPolicy(allowlist = it, _json = json) } + ?: NetworkPolicy(_json = json) + } + } + + return NetworkPolicy(_json = json) + } + } + + internal class Serializer : BaseSerializer(NetworkPolicy::class) { + + override fun serialize( + value: NetworkPolicy, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.disabled != null -> generator.writeObject(value.disabled) + value.allowlist != null -> generator.writeObject(value.allowlist) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid NetworkPolicy") + } + } + } + } + + @JsonDeserialize(using = Skill.Deserializer::class) + @JsonSerialize(using = Skill.Serializer::class) + class Skill + private constructor( + private val reference: SkillReference? = null, + private val inline: InlineSkill? = null, + private val _json: JsonValue? = null, + ) { + + fun reference(): Optional = Optional.ofNullable(reference) + + fun inline(): Optional = Optional.ofNullable(inline) + + fun isReference(): Boolean = reference != null + + fun isInline(): Boolean = inline != null + + fun asReference(): SkillReference = reference.getOrThrow("reference") + + fun asInline(): InlineSkill = inline.getOrThrow("inline") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + reference != null -> visitor.visitReference(reference) + inline != null -> visitor.visitInline(inline) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Skill = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitReference(reference: SkillReference) { + reference.validate() + } + + override fun visitInline(inline: InlineSkill) { + inline.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitReference(reference: SkillReference) = reference.validity() + + override fun visitInline(inline: InlineSkill) = inline.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Skill && reference == other.reference && inline == other.inline + } + + override fun hashCode(): Int = Objects.hash(reference, inline) + + override fun toString(): String = + when { + reference != null -> "Skill{reference=$reference}" + inline != null -> "Skill{inline=$inline}" + _json != null -> "Skill{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Skill") + } + + companion object { + + @JvmStatic fun ofReference(reference: SkillReference) = Skill(reference = reference) + + @JvmStatic fun ofInline(inline: InlineSkill) = Skill(inline = inline) + } + + /** An interface that defines how to map each variant of [Skill] to a value of type [T]. */ + interface Visitor { + + fun visitReference(reference: SkillReference): T + + fun visitInline(inline: InlineSkill): T + + /** + * Maps an unknown variant of [Skill] to a value of type [T]. + * + * An instance of [Skill] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown Skill: $json") + } + } + + internal class Deserializer : BaseDeserializer(Skill::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Skill { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "skill_reference" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Skill(reference = it, _json = json) + } ?: Skill(_json = json) + } + "inline" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Skill(inline = it, _json = json) + } ?: Skill(_json = json) + } + } + + return Skill(_json = json) + } + } + + internal class Serializer : BaseSerializer(Skill::class) { + + override fun serialize( + value: Skill, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.reference != null -> generator.writeObject(value.reference) + value.inline != null -> generator.writeObject(value.inline) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Skill") + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt index 803ee160..f5560444 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt @@ -11,7 +11,9 @@ import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkKnown import com.openai.core.checkRequired +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects @@ -29,6 +31,7 @@ private constructor( private val expiresAfter: JsonField, private val lastActiveAt: JsonField, private val memoryLimit: JsonField, + private val networkPolicy: JsonField, private val additionalProperties: MutableMap, ) { @@ -48,6 +51,9 @@ private constructor( @JsonProperty("memory_limit") @ExcludeMissing memoryLimit: JsonField = JsonMissing.of(), + @JsonProperty("network_policy") + @ExcludeMissing + networkPolicy: JsonField = JsonMissing.of(), ) : this( id, createdAt, @@ -57,6 +63,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, mutableMapOf(), ) @@ -126,6 +133,14 @@ private constructor( */ fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** + * Network access policy for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkPolicy(): Optional = networkPolicy.getOptional("network_policy") + /** * Returns the raw JSON value of [id]. * @@ -188,6 +203,15 @@ private constructor( @ExcludeMissing fun _memoryLimit(): JsonField = memoryLimit + /** + * Returns the raw JSON value of [networkPolicy]. + * + * Unlike [networkPolicy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network_policy") + @ExcludeMissing + fun _networkPolicy(): JsonField = networkPolicy + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -228,6 +252,7 @@ private constructor( private var expiresAfter: JsonField = JsonMissing.of() private var lastActiveAt: JsonField = JsonMissing.of() private var memoryLimit: JsonField = JsonMissing.of() + private var networkPolicy: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,6 +265,7 @@ private constructor( expiresAfter = containerCreateResponse.expiresAfter lastActiveAt = containerCreateResponse.lastActiveAt memoryLimit = containerCreateResponse.memoryLimit + networkPolicy = containerCreateResponse.networkPolicy additionalProperties = containerCreateResponse.additionalProperties.toMutableMap() } @@ -342,6 +368,20 @@ private constructor( this.memoryLimit = memoryLimit } + /** Network access policy for the container. */ + fun networkPolicy(networkPolicy: NetworkPolicy) = networkPolicy(JsonField.of(networkPolicy)) + + /** + * Sets [Builder.networkPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.networkPolicy] with a well-typed [NetworkPolicy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkPolicy(networkPolicy: JsonField) = apply { + this.networkPolicy = networkPolicy + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -387,6 +427,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, additionalProperties.toMutableMap(), ) } @@ -406,6 +447,7 @@ private constructor( expiresAfter().ifPresent { it.validate() } lastActiveAt() memoryLimit().ifPresent { it.validate() } + networkPolicy().ifPresent { it.validate() } validated = true } @@ -431,7 +473,8 @@ private constructor( (if (status.asKnown().isPresent) 1 else 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (if (lastActiveAt.asKnown().isPresent) 1 else 0) + - (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + + (networkPolicy.asKnown().getOrNull()?.validity() ?: 0) /** * The container will expire after this time period. The anchor is the reference point for the @@ -881,6 +924,353 @@ private constructor( override fun toString() = value.toString() } + /** Network access policy for the container. */ + class NetworkPolicy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val allowedDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("allowed_domains") + @ExcludeMissing + allowedDomains: JsonField> = JsonMissing.of(), + ) : this(type, allowedDomains, mutableMapOf()) + + /** + * The network policy mode. + * + * @throws OpenAIInvalidDataException 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 type(): Type = type.getRequired("type") + + /** + * Allowed outbound domains when `type` is `allowlist`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedDomains(): Optional> = allowedDomains.getOptional("allowed_domains") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [allowedDomains]. + * + * Unlike [allowedDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_domains") + @ExcludeMissing + fun _allowedDomains(): JsonField> = allowedDomains + + @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 [NetworkPolicy]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkPolicy]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var allowedDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkPolicy: NetworkPolicy) = apply { + type = networkPolicy.type + allowedDomains = networkPolicy.allowedDomains.map { it.toMutableList() } + additionalProperties = networkPolicy.additionalProperties.toMutableMap() + } + + /** The network policy mode. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Allowed outbound domains when `type` is `allowlist`. */ + fun allowedDomains(allowedDomains: List) = + allowedDomains(JsonField.of(allowedDomains)) + + /** + * Sets [Builder.allowedDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowedDomains(allowedDomains: JsonField>) = apply { + this.allowedDomains = allowedDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [allowedDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedDomain(allowedDomain: String) = apply { + allowedDomains = + (allowedDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedDomains", it).add(allowedDomain) + } + } + + 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 [NetworkPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkPolicy = + NetworkPolicy( + checkRequired("type", type), + (allowedDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkPolicy = apply { + if (validated) { + return@apply + } + + type().validate() + allowedDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (allowedDomains.asKnown().getOrNull()?.size ?: 0) + + /** The network policy mode. */ + class Type @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 ALLOWLIST = of("allowlist") + + @JvmField val DISABLED = of("disabled") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ALLOWLIST, + DISABLED, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + ALLOWLIST, + DISABLED, + /** An enum member indicating that [Type] 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) { + ALLOWLIST -> Value.ALLOWLIST + DISABLED -> Value.DISABLED + 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 OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOWLIST -> Known.ALLOWLIST + DISABLED -> Known.DISABLED + else -> throw OpenAIInvalidDataException("Unknown Type: $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 OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenAIInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 Type && 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 NetworkPolicy && + type == other.type && + allowedDomains == other.allowedDomains && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, allowedDomains, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkPolicy{type=$type, allowedDomains=$allowedDomains, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -895,6 +1285,7 @@ private constructor( expiresAfter == other.expiresAfter && lastActiveAt == other.lastActiveAt && memoryLimit == other.memoryLimit && + networkPolicy == other.networkPolicy && additionalProperties == other.additionalProperties } @@ -908,6 +1299,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, additionalProperties, ) } @@ -915,5 +1307,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ContainerCreateResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" + "ContainerCreateResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, networkPolicy=$networkPolicy, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt index 8f49d699..a81fb221 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt @@ -18,6 +18,7 @@ class ContainerListParams private constructor( private val after: String?, private val limit: Long?, + private val name: String?, private val order: Order?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -36,6 +37,9 @@ private constructor( */ fun limit(): Optional = Optional.ofNullable(limit) + /** Filter results by container name. */ + fun name(): Optional = Optional.ofNullable(name) + /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` * for descending order. @@ -63,6 +67,7 @@ private constructor( private var after: String? = null private var limit: Long? = null + private var name: String? = null private var order: Order? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -71,6 +76,7 @@ private constructor( internal fun from(containerListParams: ContainerListParams) = apply { after = containerListParams.after limit = containerListParams.limit + name = containerListParams.name order = containerListParams.order additionalHeaders = containerListParams.additionalHeaders.toBuilder() additionalQueryParams = containerListParams.additionalQueryParams.toBuilder() @@ -103,6 +109,12 @@ private constructor( /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ fun limit(limit: Optional) = limit(limit.getOrNull()) + /** Filter results by container name. */ + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and * `desc` for descending order. @@ -219,6 +231,7 @@ private constructor( ContainerListParams( after, limit, + name, order, additionalHeaders.build(), additionalQueryParams.build(), @@ -232,6 +245,7 @@ private constructor( .apply { after?.let { put("after", it) } limit?.let { put("limit", it.toString()) } + name?.let { put("name", it) } order?.let { put("order", it.toString()) } putAll(additionalQueryParams) } @@ -374,14 +388,15 @@ private constructor( return other is ContainerListParams && after == other.after && limit == other.limit && + name == other.name && order == other.order && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(after, limit, order, additionalHeaders, additionalQueryParams) + Objects.hash(after, limit, name, order, additionalHeaders, additionalQueryParams) override fun toString() = - "ContainerListParams{after=$after, limit=$limit, order=$order, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ContainerListParams{after=$after, limit=$limit, name=$name, order=$order, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt index d8f8b9bf..e1b54962 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt @@ -11,7 +11,9 @@ import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkKnown import com.openai.core.checkRequired +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects @@ -29,6 +31,7 @@ private constructor( private val expiresAfter: JsonField, private val lastActiveAt: JsonField, private val memoryLimit: JsonField, + private val networkPolicy: JsonField, private val additionalProperties: MutableMap, ) { @@ -48,6 +51,9 @@ private constructor( @JsonProperty("memory_limit") @ExcludeMissing memoryLimit: JsonField = JsonMissing.of(), + @JsonProperty("network_policy") + @ExcludeMissing + networkPolicy: JsonField = JsonMissing.of(), ) : this( id, createdAt, @@ -57,6 +63,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, mutableMapOf(), ) @@ -126,6 +133,14 @@ private constructor( */ fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** + * Network access policy for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkPolicy(): Optional = networkPolicy.getOptional("network_policy") + /** * Returns the raw JSON value of [id]. * @@ -188,6 +203,15 @@ private constructor( @ExcludeMissing fun _memoryLimit(): JsonField = memoryLimit + /** + * Returns the raw JSON value of [networkPolicy]. + * + * Unlike [networkPolicy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network_policy") + @ExcludeMissing + fun _networkPolicy(): JsonField = networkPolicy + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -228,6 +252,7 @@ private constructor( private var expiresAfter: JsonField = JsonMissing.of() private var lastActiveAt: JsonField = JsonMissing.of() private var memoryLimit: JsonField = JsonMissing.of() + private var networkPolicy: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,6 +265,7 @@ private constructor( expiresAfter = containerListResponse.expiresAfter lastActiveAt = containerListResponse.lastActiveAt memoryLimit = containerListResponse.memoryLimit + networkPolicy = containerListResponse.networkPolicy additionalProperties = containerListResponse.additionalProperties.toMutableMap() } @@ -342,6 +368,20 @@ private constructor( this.memoryLimit = memoryLimit } + /** Network access policy for the container. */ + fun networkPolicy(networkPolicy: NetworkPolicy) = networkPolicy(JsonField.of(networkPolicy)) + + /** + * Sets [Builder.networkPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.networkPolicy] with a well-typed [NetworkPolicy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkPolicy(networkPolicy: JsonField) = apply { + this.networkPolicy = networkPolicy + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -387,6 +427,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, additionalProperties.toMutableMap(), ) } @@ -406,6 +447,7 @@ private constructor( expiresAfter().ifPresent { it.validate() } lastActiveAt() memoryLimit().ifPresent { it.validate() } + networkPolicy().ifPresent { it.validate() } validated = true } @@ -431,7 +473,8 @@ private constructor( (if (status.asKnown().isPresent) 1 else 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (if (lastActiveAt.asKnown().isPresent) 1 else 0) + - (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + + (networkPolicy.asKnown().getOrNull()?.validity() ?: 0) /** * The container will expire after this time period. The anchor is the reference point for the @@ -881,6 +924,353 @@ private constructor( override fun toString() = value.toString() } + /** Network access policy for the container. */ + class NetworkPolicy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val allowedDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("allowed_domains") + @ExcludeMissing + allowedDomains: JsonField> = JsonMissing.of(), + ) : this(type, allowedDomains, mutableMapOf()) + + /** + * The network policy mode. + * + * @throws OpenAIInvalidDataException 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 type(): Type = type.getRequired("type") + + /** + * Allowed outbound domains when `type` is `allowlist`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedDomains(): Optional> = allowedDomains.getOptional("allowed_domains") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [allowedDomains]. + * + * Unlike [allowedDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_domains") + @ExcludeMissing + fun _allowedDomains(): JsonField> = allowedDomains + + @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 [NetworkPolicy]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkPolicy]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var allowedDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkPolicy: NetworkPolicy) = apply { + type = networkPolicy.type + allowedDomains = networkPolicy.allowedDomains.map { it.toMutableList() } + additionalProperties = networkPolicy.additionalProperties.toMutableMap() + } + + /** The network policy mode. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Allowed outbound domains when `type` is `allowlist`. */ + fun allowedDomains(allowedDomains: List) = + allowedDomains(JsonField.of(allowedDomains)) + + /** + * Sets [Builder.allowedDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowedDomains(allowedDomains: JsonField>) = apply { + this.allowedDomains = allowedDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [allowedDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedDomain(allowedDomain: String) = apply { + allowedDomains = + (allowedDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedDomains", it).add(allowedDomain) + } + } + + 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 [NetworkPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkPolicy = + NetworkPolicy( + checkRequired("type", type), + (allowedDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkPolicy = apply { + if (validated) { + return@apply + } + + type().validate() + allowedDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (allowedDomains.asKnown().getOrNull()?.size ?: 0) + + /** The network policy mode. */ + class Type @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 ALLOWLIST = of("allowlist") + + @JvmField val DISABLED = of("disabled") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ALLOWLIST, + DISABLED, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + ALLOWLIST, + DISABLED, + /** An enum member indicating that [Type] 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) { + ALLOWLIST -> Value.ALLOWLIST + DISABLED -> Value.DISABLED + 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 OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOWLIST -> Known.ALLOWLIST + DISABLED -> Known.DISABLED + else -> throw OpenAIInvalidDataException("Unknown Type: $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 OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenAIInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 Type && 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 NetworkPolicy && + type == other.type && + allowedDomains == other.allowedDomains && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, allowedDomains, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkPolicy{type=$type, allowedDomains=$allowedDomains, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -895,6 +1285,7 @@ private constructor( expiresAfter == other.expiresAfter && lastActiveAt == other.lastActiveAt && memoryLimit == other.memoryLimit && + networkPolicy == other.networkPolicy && additionalProperties == other.additionalProperties } @@ -908,6 +1299,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, additionalProperties, ) } @@ -915,5 +1307,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ContainerListResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" + "ContainerListResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, networkPolicy=$networkPolicy, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt index 59ab1ad1..9c05fc02 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt @@ -11,7 +11,9 @@ import com.openai.core.ExcludeMissing import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue +import com.openai.core.checkKnown import com.openai.core.checkRequired +import com.openai.core.toImmutable import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects @@ -29,6 +31,7 @@ private constructor( private val expiresAfter: JsonField, private val lastActiveAt: JsonField, private val memoryLimit: JsonField, + private val networkPolicy: JsonField, private val additionalProperties: MutableMap, ) { @@ -48,6 +51,9 @@ private constructor( @JsonProperty("memory_limit") @ExcludeMissing memoryLimit: JsonField = JsonMissing.of(), + @JsonProperty("network_policy") + @ExcludeMissing + networkPolicy: JsonField = JsonMissing.of(), ) : this( id, createdAt, @@ -57,6 +63,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, mutableMapOf(), ) @@ -126,6 +133,14 @@ private constructor( */ fun memoryLimit(): Optional = memoryLimit.getOptional("memory_limit") + /** + * Network access policy for the container. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkPolicy(): Optional = networkPolicy.getOptional("network_policy") + /** * Returns the raw JSON value of [id]. * @@ -188,6 +203,15 @@ private constructor( @ExcludeMissing fun _memoryLimit(): JsonField = memoryLimit + /** + * Returns the raw JSON value of [networkPolicy]. + * + * Unlike [networkPolicy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network_policy") + @ExcludeMissing + fun _networkPolicy(): JsonField = networkPolicy + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -228,6 +252,7 @@ private constructor( private var expiresAfter: JsonField = JsonMissing.of() private var lastActiveAt: JsonField = JsonMissing.of() private var memoryLimit: JsonField = JsonMissing.of() + private var networkPolicy: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -240,6 +265,7 @@ private constructor( expiresAfter = containerRetrieveResponse.expiresAfter lastActiveAt = containerRetrieveResponse.lastActiveAt memoryLimit = containerRetrieveResponse.memoryLimit + networkPolicy = containerRetrieveResponse.networkPolicy additionalProperties = containerRetrieveResponse.additionalProperties.toMutableMap() } @@ -342,6 +368,20 @@ private constructor( this.memoryLimit = memoryLimit } + /** Network access policy for the container. */ + fun networkPolicy(networkPolicy: NetworkPolicy) = networkPolicy(JsonField.of(networkPolicy)) + + /** + * Sets [Builder.networkPolicy] to an arbitrary JSON value. + * + * You should usually call [Builder.networkPolicy] with a well-typed [NetworkPolicy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkPolicy(networkPolicy: JsonField) = apply { + this.networkPolicy = networkPolicy + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -387,6 +427,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, additionalProperties.toMutableMap(), ) } @@ -406,6 +447,7 @@ private constructor( expiresAfter().ifPresent { it.validate() } lastActiveAt() memoryLimit().ifPresent { it.validate() } + networkPolicy().ifPresent { it.validate() } validated = true } @@ -431,7 +473,8 @@ private constructor( (if (status.asKnown().isPresent) 1 else 0) + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + (if (lastActiveAt.asKnown().isPresent) 1 else 0) + - (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + (memoryLimit.asKnown().getOrNull()?.validity() ?: 0) + + (networkPolicy.asKnown().getOrNull()?.validity() ?: 0) /** * The container will expire after this time period. The anchor is the reference point for the @@ -881,6 +924,353 @@ private constructor( override fun toString() = value.toString() } + /** Network access policy for the container. */ + class NetworkPolicy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val allowedDomains: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("allowed_domains") + @ExcludeMissing + allowedDomains: JsonField> = JsonMissing.of(), + ) : this(type, allowedDomains, mutableMapOf()) + + /** + * The network policy mode. + * + * @throws OpenAIInvalidDataException 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 type(): Type = type.getRequired("type") + + /** + * Allowed outbound domains when `type` is `allowlist`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowedDomains(): Optional> = allowedDomains.getOptional("allowed_domains") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [allowedDomains]. + * + * Unlike [allowedDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("allowed_domains") + @ExcludeMissing + fun _allowedDomains(): JsonField> = allowedDomains + + @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 [NetworkPolicy]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkPolicy]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var allowedDomains: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkPolicy: NetworkPolicy) = apply { + type = networkPolicy.type + allowedDomains = networkPolicy.allowedDomains.map { it.toMutableList() } + additionalProperties = networkPolicy.additionalProperties.toMutableMap() + } + + /** The network policy mode. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Allowed outbound domains when `type` is `allowlist`. */ + fun allowedDomains(allowedDomains: List) = + allowedDomains(JsonField.of(allowedDomains)) + + /** + * Sets [Builder.allowedDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.allowedDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowedDomains(allowedDomains: JsonField>) = apply { + this.allowedDomains = allowedDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [allowedDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowedDomain(allowedDomain: String) = apply { + allowedDomains = + (allowedDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("allowedDomains", it).add(allowedDomain) + } + } + + 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 [NetworkPolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkPolicy = + NetworkPolicy( + checkRequired("type", type), + (allowedDomains ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkPolicy = apply { + if (validated) { + return@apply + } + + type().validate() + allowedDomains() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (allowedDomains.asKnown().getOrNull()?.size ?: 0) + + /** The network policy mode. */ + class Type @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 ALLOWLIST = of("allowlist") + + @JvmField val DISABLED = of("disabled") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ALLOWLIST, + DISABLED, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + ALLOWLIST, + DISABLED, + /** An enum member indicating that [Type] 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) { + ALLOWLIST -> Value.ALLOWLIST + DISABLED -> Value.DISABLED + 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 OpenAIInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALLOWLIST -> Known.ALLOWLIST + DISABLED -> Known.DISABLED + else -> throw OpenAIInvalidDataException("Unknown Type: $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 OpenAIInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + OpenAIInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + 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 Type && 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 NetworkPolicy && + type == other.type && + allowedDomains == other.allowedDomains && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(type, allowedDomains, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkPolicy{type=$type, allowedDomains=$allowedDomains, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -895,6 +1285,7 @@ private constructor( expiresAfter == other.expiresAfter && lastActiveAt == other.lastActiveAt && memoryLimit == other.memoryLimit && + networkPolicy == other.networkPolicy && additionalProperties == other.additionalProperties } @@ -908,6 +1299,7 @@ private constructor( expiresAfter, lastActiveAt, memoryLimit, + networkPolicy, additionalProperties, ) } @@ -915,5 +1307,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ContainerRetrieveResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, additionalProperties=$additionalProperties}" + "ContainerRetrieveResponse{id=$id, createdAt=$createdAt, name=$name, object_=$object_, status=$status, expiresAfter=$expiresAfter, lastActiveAt=$lastActiveAt, memoryLimit=$memoryLimit, networkPolicy=$networkPolicy, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt index d0231163..4c89f914 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateParamsTest.kt @@ -2,6 +2,8 @@ package com.openai.models.containers +import com.openai.models.responses.ContainerNetworkPolicyDisabled +import com.openai.models.responses.SkillReference import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -20,6 +22,8 @@ internal class ContainerCreateParamsTest { ) .addFileId("string") .memoryLimit(ContainerCreateParams.MemoryLimit._1G) + .networkPolicy(ContainerNetworkPolicyDisabled.builder().build()) + .addSkill(SkillReference.builder().skillId("x").version("version").build()) .build() } @@ -36,6 +40,8 @@ internal class ContainerCreateParamsTest { ) .addFileId("string") .memoryLimit(ContainerCreateParams.MemoryLimit._1G) + .networkPolicy(ContainerNetworkPolicyDisabled.builder().build()) + .addSkill(SkillReference.builder().skillId("x").version("version").build()) .build() val body = params._body() @@ -50,6 +56,18 @@ internal class ContainerCreateParamsTest { ) assertThat(body.fileIds().getOrNull()).containsExactly("string") assertThat(body.memoryLimit()).contains(ContainerCreateParams.MemoryLimit._1G) + assertThat(body.networkPolicy()) + .contains( + ContainerCreateParams.NetworkPolicy.ofDisabled( + ContainerNetworkPolicyDisabled.builder().build() + ) + ) + assertThat(body.skills().getOrNull()) + .containsExactly( + ContainerCreateParams.Skill.ofReference( + SkillReference.builder().skillId("x").version("version").build() + ) + ) } @Test diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt index 4088c082..c67fea5d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerCreateResponseTest.kt @@ -26,6 +26,12 @@ internal class ContainerCreateResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerCreateResponse.MemoryLimit._1G) + .networkPolicy( + ContainerCreateResponse.NetworkPolicy.builder() + .type(ContainerCreateResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() assertThat(containerCreateResponse.id()).isEqualTo("id") @@ -43,6 +49,13 @@ internal class ContainerCreateResponseTest { assertThat(containerCreateResponse.lastActiveAt()).contains(0L) assertThat(containerCreateResponse.memoryLimit()) .contains(ContainerCreateResponse.MemoryLimit._1G) + assertThat(containerCreateResponse.networkPolicy()) + .contains( + ContainerCreateResponse.NetworkPolicy.builder() + .type(ContainerCreateResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) } @Test @@ -63,6 +76,12 @@ internal class ContainerCreateResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerCreateResponse.MemoryLimit._1G) + .networkPolicy( + ContainerCreateResponse.NetworkPolicy.builder() + .type(ContainerCreateResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() val roundtrippedContainerCreateResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt index 4c545bbf..d69adec4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListPageResponseTest.kt @@ -28,6 +28,12 @@ internal class ContainerListPageResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerListResponse.MemoryLimit._1G) + .networkPolicy( + ContainerListResponse.NetworkPolicy.builder() + .type(ContainerListResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() ) .firstId("first_id") @@ -51,6 +57,12 @@ internal class ContainerListPageResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerListResponse.MemoryLimit._1G) + .networkPolicy( + ContainerListResponse.NetworkPolicy.builder() + .type(ContainerListResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() ) assertThat(containerListPageResponse.firstId()).isEqualTo("first_id") @@ -78,6 +90,12 @@ internal class ContainerListPageResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerListResponse.MemoryLimit._1G) + .networkPolicy( + ContainerListResponse.NetworkPolicy.builder() + .type(ContainerListResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() ) .firstId("first_id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListParamsTest.kt index aad4af8b..10345016 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListParamsTest.kt @@ -13,6 +13,7 @@ internal class ContainerListParamsTest { ContainerListParams.builder() .after("after") .limit(0L) + .name("name") .order(ContainerListParams.Order.ASC) .build() } @@ -23,6 +24,7 @@ internal class ContainerListParamsTest { ContainerListParams.builder() .after("after") .limit(0L) + .name("name") .order(ContainerListParams.Order.ASC) .build() @@ -33,6 +35,7 @@ internal class ContainerListParamsTest { QueryParams.builder() .put("after", "after") .put("limit", "0") + .put("name", "name") .put("order", "asc") .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt index 63d28719..cad6d249 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerListResponseTest.kt @@ -26,6 +26,12 @@ internal class ContainerListResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerListResponse.MemoryLimit._1G) + .networkPolicy( + ContainerListResponse.NetworkPolicy.builder() + .type(ContainerListResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() assertThat(containerListResponse.id()).isEqualTo("id") @@ -43,6 +49,13 @@ internal class ContainerListResponseTest { assertThat(containerListResponse.lastActiveAt()).contains(0L) assertThat(containerListResponse.memoryLimit()) .contains(ContainerListResponse.MemoryLimit._1G) + assertThat(containerListResponse.networkPolicy()) + .contains( + ContainerListResponse.NetworkPolicy.builder() + .type(ContainerListResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) } @Test @@ -63,6 +76,12 @@ internal class ContainerListResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerListResponse.MemoryLimit._1G) + .networkPolicy( + ContainerListResponse.NetworkPolicy.builder() + .type(ContainerListResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() val roundtrippedContainerListResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt index 30b03278..9870e6f6 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/containers/ContainerRetrieveResponseTest.kt @@ -26,6 +26,12 @@ internal class ContainerRetrieveResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerRetrieveResponse.MemoryLimit._1G) + .networkPolicy( + ContainerRetrieveResponse.NetworkPolicy.builder() + .type(ContainerRetrieveResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() assertThat(containerRetrieveResponse.id()).isEqualTo("id") @@ -43,6 +49,13 @@ internal class ContainerRetrieveResponseTest { assertThat(containerRetrieveResponse.lastActiveAt()).contains(0L) assertThat(containerRetrieveResponse.memoryLimit()) .contains(ContainerRetrieveResponse.MemoryLimit._1G) + assertThat(containerRetrieveResponse.networkPolicy()) + .contains( + ContainerRetrieveResponse.NetworkPolicy.builder() + .type(ContainerRetrieveResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) } @Test @@ -63,6 +76,12 @@ internal class ContainerRetrieveResponseTest { ) .lastActiveAt(0L) .memoryLimit(ContainerRetrieveResponse.MemoryLimit._1G) + .networkPolicy( + ContainerRetrieveResponse.NetworkPolicy.builder() + .type(ContainerRetrieveResponse.NetworkPolicy.Type.ALLOWLIST) + .addAllowedDomain("string") + .build() + ) .build() val roundtrippedContainerRetrieveResponse = diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt index c969f669..c19ce9a4 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/ContainerServiceAsyncTest.kt @@ -5,6 +5,8 @@ package com.openai.services.async import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClientAsync import com.openai.models.containers.ContainerCreateParams +import com.openai.models.responses.ContainerNetworkPolicyDisabled +import com.openai.models.responses.SkillReference import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -32,6 +34,8 @@ internal class ContainerServiceAsyncTest { ) .addFileId("string") .memoryLimit(ContainerCreateParams.MemoryLimit._1G) + .networkPolicy(ContainerNetworkPolicyDisabled.builder().build()) + .addSkill(SkillReference.builder().skillId("x").version("version").build()) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt index 1bbd9926..90faaaaa 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ContainerServiceTest.kt @@ -5,6 +5,8 @@ package com.openai.services.blocking import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClient import com.openai.models.containers.ContainerCreateParams +import com.openai.models.responses.ContainerNetworkPolicyDisabled +import com.openai.models.responses.SkillReference import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -32,6 +34,8 @@ internal class ContainerServiceTest { ) .addFileId("string") .memoryLimit(ContainerCreateParams.MemoryLimit._1G) + .networkPolicy(ContainerNetworkPolicyDisabled.builder().build()) + .addSkill(SkillReference.builder().skillId("x").version("version").build()) .build() ) From 15a89e54d822d96c67aab1d63606efc41a7655dc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 19:14:10 +0000 Subject: [PATCH 5/5] release: 4.21.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 13 +++++++++++++ README.md | 14 +++++++------- build.gradle.kts | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 88e4c443..b9e06599 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.20.0" + ".": "4.21.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fb30ec13..6af0d9c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 4.21.0 (2026-02-13) + +Full Changelog: [v4.20.0...v4.21.0](https://github.com/openai/openai-java/compare/v4.20.0...v4.21.0) + +### Features + +* **api:** container network_policy and skills ([c248c52](https://github.com/openai/openai-java/commit/c248c522e1ef826aa28c1176dee234ba64bc0550)) + + +### Documentation + +* update comment ([6a1a02b](https://github.com/openai/openai-java/commit/6a1a02b54a87dc5ad846086f4ca0eda047928720)) + ## 4.20.0 (2026-02-10) Full Changelog: [v4.19.0...v4.20.0](https://github.com/openai/openai-java/compare/v4.19.0...v4.20.0) diff --git a/README.md b/README.md index fd9f5aff..8782bd66 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.20.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.20.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.20.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.21.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.21.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.21.0) @@ -11,7 +11,7 @@ The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https:// -The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.20.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.21.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor ### Gradle ```kotlin -implementation("com.openai:openai-java:4.20.0") +implementation("com.openai:openai-java:4.21.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.20.0") com.openai openai-java - 4.20.0 + 4.21.0 ``` @@ -1342,7 +1342,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht #### Gradle ```kotlin -implementation("com.openai:openai-java-spring-boot-starter:4.20.0") +implementation("com.openai:openai-java-spring-boot-starter:4.21.0") ``` #### Maven @@ -1351,7 +1351,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.20.0") com.openai openai-java-spring-boot-starter - 4.20.0 + 4.21.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 5849b5ef..a025fa59 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "4.20.0" // x-release-please-version + version = "4.21.0" // x-release-please-version } subprojects {