diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 1bae6b6d9..a92bd0cac 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.39.1" + ".": "4.40.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 25e6ceff0..ceecd31fa 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 261 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-0161cb2a0faadedfc17ff59c7fcad9671962dbd170f83811003c23702148cf36.yml -openapi_spec_hash: 1023c7442d0e2e7e213e8b3a253921c5 -config_hash: e02ca1082421dfe55b145c45e95d6126 +configured_endpoints: 263 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-4db8edc05bd5503d4aaad74e8b9c783aa1f4d40382a8075c53355bd18dfaf68c.yml +openapi_spec_hash: 2466f6ad496b27334217999202e185c0 +config_hash: ef3ce17315a31703e7af0567b3e9738c diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb571b68..ed847f582 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 4.40.0 (2026-06-16) + +Full Changelog: [v4.39.1...v4.40.0](https://github.com/openai/openai-java/compare/v4.39.1...v4.40.0) + +### Features + +* **api:** admin spend_alerts ([512770c](https://github.com/openai/openai-java/commit/512770c119201347bfab9e68fec00e1cff5b2df8)) +* **api:** manual updates ([701ebe0](https://github.com/openai/openai-java/commit/701ebe011fa2ed05f80e51307bc7e9886bfb9d8b)) +* **api:** update OpenAPI spec or Stainless config ([94b7412](https://github.com/openai/openai-java/commit/94b7412a98fb60d6865d362c48526b4a6dd0896a)) + + +### Build System + +* Use CI environment for OpenAI API key workflow ([#756](https://github.com/openai/openai-java/issues/756)) ([27de5f5](https://github.com/openai/openai-java/commit/27de5f5b159394b7f29a31389854890460122c1a)) +* Use publish environment for release job ([#758](https://github.com/openai/openai-java/issues/758)) ([bbb66f8](https://github.com/openai/openai-java/commit/bbb66f870877a3e9e3f73c5c41eb4558f23a901a)) + ## 4.39.1 (2026-06-04) Full Changelog: [v4.39.0...v4.39.1](https://github.com/openai/openai-java/compare/v4.39.0...v4.39.1) diff --git a/README.md b/README.md index f6d59ac27..d54a09e10 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.39.1) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.39.1/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.39.1) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.40.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.40.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.40.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.39.1). +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.40.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.39.1") +implementation("com.openai:openai-java:4.40.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.39.1") com.openai openai-java - 4.39.1 + 4.40.0 ``` @@ -1433,7 +1433,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.39.1") +implementation("com.openai:openai-java-spring-boot-starter:4.40.0") ``` #### Maven @@ -1442,7 +1442,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.39.1") com.openai openai-java-spring-boot-starter - 4.39.1 + 4.40.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 46b0ae66b..eb92da758 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "4.39.1" // x-release-please-version + version = "4.40.0" // x-release-please-version } subprojects { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt b/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt index 224a76108..285ebff40 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Reasoning.kt @@ -25,6 +25,7 @@ import kotlin.jvm.optionals.getOrNull class Reasoning @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val context: JsonField, private val effort: JsonField, private val generateSummary: JsonField, private val summary: JsonField, @@ -33,6 +34,7 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("context") @ExcludeMissing context: JsonField = JsonMissing.of(), @JsonProperty("effort") @ExcludeMissing effort: JsonField = JsonMissing.of(), @@ -40,7 +42,16 @@ private constructor( @ExcludeMissing generateSummary: JsonField = JsonMissing.of(), @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), - ) : this(effort, generateSummary, summary, mutableMapOf()) + ) : this(context, effort, generateSummary, summary, mutableMapOf()) + + /** + * Controls which reasoning items are rendered back to the model on later turns. When returned + * on a response, this is the effective reasoning context mode used for the response. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") /** * Constrains effort on reasoning for @@ -85,6 +96,13 @@ private constructor( */ fun summary(): Optional = summary.getOptional("summary") + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + /** * Returns the raw JSON value of [effort]. * @@ -130,6 +148,7 @@ private constructor( /** A builder for [Reasoning]. */ class Builder internal constructor() { + private var context: JsonField = JsonMissing.of() private var effort: JsonField = JsonMissing.of() private var generateSummary: JsonField = JsonMissing.of() private var summary: JsonField = JsonMissing.of() @@ -137,12 +156,31 @@ private constructor( @JvmSynthetic internal fun from(reasoning: Reasoning) = apply { + context = reasoning.context effort = reasoning.effort generateSummary = reasoning.generateSummary summary = reasoning.summary additionalProperties = reasoning.additionalProperties.toMutableMap() } + /** + * Controls which reasoning items are rendered back to the model on later turns. When + * returned on a response, this is the effective reasoning context mode used for the + * response. + */ + fun context(context: Context?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [Context] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + /** * Constrains effort on reasoning for * [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently @@ -243,7 +281,13 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Reasoning = - Reasoning(effort, generateSummary, summary, additionalProperties.toMutableMap()) + Reasoning( + context, + effort, + generateSummary, + summary, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -261,6 +305,7 @@ private constructor( return@apply } + context().ifPresent { it.validate() } effort().ifPresent { it.validate() } generateSummary().ifPresent { it.validate() } summary().ifPresent { it.validate() } @@ -282,10 +327,155 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (effort.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (effort.asKnown().getOrNull()?.validity() ?: 0) + (generateSummary.asKnown().getOrNull()?.validity() ?: 0) + (summary.asKnown().getOrNull()?.validity() ?: 0) + /** + * Controls which reasoning items are rendered back to the model on later turns. When returned + * on a response, this is the effective reasoning context mode used for the response. + */ + class Context @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 AUTO = of("auto") + + @JvmField val CURRENT_TURN = of("current_turn") + + @JvmField val ALL_TURNS = of("all_turns") + + @JvmStatic fun of(value: String) = Context(JsonField.of(value)) + } + + /** An enum containing [Context]'s known values. */ + enum class Known { + AUTO, + CURRENT_TURN, + ALL_TURNS, + } + + /** + * An enum containing [Context]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Context] 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 { + AUTO, + CURRENT_TURN, + ALL_TURNS, + /** An enum member indicating that [Context] 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) { + AUTO -> Value.AUTO + CURRENT_TURN -> Value.CURRENT_TURN + ALL_TURNS -> Value.ALL_TURNS + 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) { + AUTO -> Known.AUTO + CURRENT_TURN -> Known.CURRENT_TURN + ALL_TURNS -> Known.ALL_TURNS + else -> throw OpenAIInvalidDataException("Unknown Context: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Context = 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 Context && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * **Deprecated:** use `summary` instead. * @@ -590,6 +780,7 @@ private constructor( } return other is Reasoning && + context == other.context && effort == other.effort && generateSummary == other.generateSummary && summary == other.summary && @@ -597,11 +788,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(effort, generateSummary, summary, additionalProperties) + Objects.hash(context, effort, generateSummary, summary, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Reasoning{effort=$effort, generateSummary=$generateSummary, summary=$summary, additionalProperties=$additionalProperties}" + "Reasoning{context=$context, effort=$effort, generateSummary=$generateSummary, summary=$summary, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKey.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKey.kt index feb025044..4f7026898 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKey.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKey.kt @@ -23,6 +23,7 @@ class AdminApiKey private constructor( private val id: JsonField, private val createdAt: JsonField, + private val expiresAt: JsonField, private val object_: JsonValue, private val owner: JsonField, private val redactedValue: JsonField, @@ -35,6 +36,7 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") @ExcludeMissing expiresAt: JsonField = JsonMissing.of(), @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), @JsonProperty("redacted_value") @@ -44,7 +46,17 @@ private constructor( @ExcludeMissing lastUsedAt: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, createdAt, object_, owner, redactedValue, lastUsedAt, name, mutableMapOf()) + ) : this( + id, + createdAt, + expiresAt, + object_, + owner, + redactedValue, + lastUsedAt, + name, + mutableMapOf(), + ) /** * The identifier, which can be referenced in API endpoints @@ -62,6 +74,14 @@ private constructor( */ fun createdAt(): Long = createdAt.getRequired("created_at") + /** + * The Unix timestamp (in seconds) of when the API key expires + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresAt(): Optional = expiresAt.getOptional("expires_at") + /** * The object type, which is always `organization.admin_api_key` * @@ -119,6 +139,13 @@ private constructor( */ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") @ExcludeMissing fun _expiresAt(): JsonField = expiresAt + /** * Returns the raw JSON value of [owner]. * @@ -170,6 +197,7 @@ private constructor( * ```java * .id() * .createdAt() + * .expiresAt() * .owner() * .redactedValue() * ``` @@ -182,6 +210,7 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null + private var expiresAt: JsonField? = null private var object_: JsonValue = JsonValue.from("organization.admin_api_key") private var owner: JsonField? = null private var redactedValue: JsonField? = null @@ -193,6 +222,7 @@ private constructor( internal fun from(adminApiKey: AdminApiKey) = apply { id = adminApiKey.id createdAt = adminApiKey.createdAt + expiresAt = adminApiKey.expiresAt object_ = adminApiKey.object_ owner = adminApiKey.owner redactedValue = adminApiKey.redactedValue @@ -223,6 +253,27 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** The Unix timestamp (in seconds) of when the API key expires */ + fun expiresAt(expiresAt: Long?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** + * Alias for [Builder.expiresAt]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun expiresAt(expiresAt: Long) = expiresAt(expiresAt as Long?) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } + /** * Sets the field to an arbitrary JSON value. * @@ -324,6 +375,7 @@ private constructor( * ```java * .id() * .createdAt() + * .expiresAt() * .owner() * .redactedValue() * ``` @@ -334,6 +386,7 @@ private constructor( AdminApiKey( checkRequired("id", id), checkRequired("createdAt", createdAt), + checkRequired("expiresAt", expiresAt), object_, checkRequired("owner", owner), checkRequired("redactedValue", redactedValue), @@ -360,6 +413,7 @@ private constructor( id() createdAt() + expiresAt() _object_().let { if (it != JsonValue.from("organization.admin_api_key")) { throw OpenAIInvalidDataException("'object_' is invalid, received $it") @@ -389,6 +443,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + object_.let { if (it == JsonValue.from("organization.admin_api_key")) 1 else 0 } + (owner.asKnown().getOrNull()?.validity() ?: 0) + (if (redactedValue.asKnown().isPresent) 1 else 0) + @@ -730,6 +785,7 @@ private constructor( return other is AdminApiKey && id == other.id && createdAt == other.createdAt && + expiresAt == other.expiresAt && object_ == other.object_ && owner == other.owner && redactedValue == other.redactedValue && @@ -742,6 +798,7 @@ private constructor( Objects.hash( id, createdAt, + expiresAt, object_, owner, redactedValue, @@ -754,5 +811,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AdminApiKey{id=$id, createdAt=$createdAt, object_=$object_, owner=$owner, redactedValue=$redactedValue, lastUsedAt=$lastUsedAt, name=$name, additionalProperties=$additionalProperties}" + "AdminApiKey{id=$id, createdAt=$createdAt, expiresAt=$expiresAt, object_=$object_, owner=$owner, redactedValue=$redactedValue, lastUsedAt=$lastUsedAt, name=$name, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParams.kt index f40398276..655aa1d4d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParams.kt @@ -17,6 +17,7 @@ import com.openai.core.http.QueryParams import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional /** Create an organization admin API key */ class AdminApiKeyCreateParams @@ -32,6 +33,15 @@ private constructor( */ fun name(): String = body.name() + /** + * The number of seconds until the API key expires. Omit this field for a key that does not + * expire. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresInSeconds(): Optional = body.expiresInSeconds() + /** * Returns the raw JSON value of [name]. * @@ -39,6 +49,14 @@ private constructor( */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [expiresInSeconds]. + * + * Unlike [expiresInSeconds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _expiresInSeconds(): JsonField = body._expiresInSeconds() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -82,6 +100,7 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [name] + * - [expiresInSeconds] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -95,6 +114,25 @@ private constructor( */ fun name(name: JsonField) = apply { body.name(name) } + /** + * The number of seconds until the API key expires. Omit this field for a key that does not + * expire. + */ + fun expiresInSeconds(expiresInSeconds: Long) = apply { + body.expiresInSeconds(expiresInSeconds) + } + + /** + * Sets [Builder.expiresInSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresInSeconds] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresInSeconds(expiresInSeconds: JsonField) = apply { + body.expiresInSeconds(expiresInSeconds) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -242,13 +280,17 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, + private val expiresInSeconds: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("expires_in_seconds") + @ExcludeMissing + expiresInSeconds: JsonField = JsonMissing.of(), + ) : this(name, expiresInSeconds, mutableMapOf()) /** * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is @@ -256,6 +298,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * The number of seconds until the API key expires. Omit this field for a key that does not + * expire. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresInSeconds(): Optional = expiresInSeconds.getOptional("expires_in_seconds") + /** * Returns the raw JSON value of [name]. * @@ -263,6 +314,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [expiresInSeconds]. + * + * Unlike [expiresInSeconds], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expires_in_seconds") + @ExcludeMissing + fun _expiresInSeconds(): JsonField = expiresInSeconds + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -292,11 +353,13 @@ private constructor( class Builder internal constructor() { private var name: JsonField? = null + private var expiresInSeconds: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { name = body.name + expiresInSeconds = body.expiresInSeconds additionalProperties = body.additionalProperties.toMutableMap() } @@ -311,6 +374,24 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * The number of seconds until the API key expires. Omit this field for a key that does + * not expire. + */ + fun expiresInSeconds(expiresInSeconds: Long) = + expiresInSeconds(JsonField.of(expiresInSeconds)) + + /** + * Sets [Builder.expiresInSeconds] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresInSeconds] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresInSeconds(expiresInSeconds: JsonField) = apply { + this.expiresInSeconds = expiresInSeconds + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -343,7 +424,11 @@ private constructor( * @throws IllegalStateException if any required field is unset. */ fun build(): Body = - Body(checkRequired("name", name), additionalProperties.toMutableMap()) + Body( + checkRequired("name", name), + expiresInSeconds, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -363,6 +448,7 @@ private constructor( } name() + expiresInSeconds() validated = true } @@ -380,7 +466,10 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (expiresInSeconds.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -389,14 +478,18 @@ private constructor( return other is Body && name == other.name && + expiresInSeconds == other.expiresInSeconds && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(name, expiresInSeconds, additionalProperties) + } override fun hashCode(): Int = hashCode - override fun toString() = "Body{name=$name, additionalProperties=$additionalProperties}" + override fun toString() = + "Body{name=$name, expiresInSeconds=$expiresInSeconds, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponse.kt index c7acdc7ed..5cd215793 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponse.kt @@ -23,6 +23,7 @@ class AdminApiKeyCreateResponse private constructor( private val id: JsonField, private val createdAt: JsonField, + private val expiresAt: JsonField, private val object_: JsonValue, private val owner: JsonField, private val redactedValue: JsonField, @@ -36,6 +37,7 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") @ExcludeMissing expiresAt: JsonField = JsonMissing.of(), @JsonProperty("object") @ExcludeMissing object_: JsonValue = JsonMissing.of(), @JsonProperty("owner") @ExcludeMissing @@ -48,12 +50,24 @@ private constructor( lastUsedAt: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(id, createdAt, object_, owner, redactedValue, lastUsedAt, name, value, mutableMapOf()) + ) : this( + id, + createdAt, + expiresAt, + object_, + owner, + redactedValue, + lastUsedAt, + name, + value, + mutableMapOf(), + ) fun toAdminApiKey(): AdminApiKey = AdminApiKey.builder() .id(id) .createdAt(createdAt) + .expiresAt(expiresAt) .object_(object_) .owner(owner) .redactedValue(redactedValue) @@ -77,6 +91,14 @@ private constructor( */ fun createdAt(): Long = createdAt.getRequired("created_at") + /** + * The Unix timestamp (in seconds) of when the API key expires + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresAt(): Optional = expiresAt.getOptional("expires_at") + /** * The object type, which is always `organization.admin_api_key` * @@ -142,6 +164,13 @@ private constructor( */ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") @ExcludeMissing fun _expiresAt(): JsonField = expiresAt + /** * Returns the raw JSON value of [owner]. * @@ -200,6 +229,7 @@ private constructor( * ```java * .id() * .createdAt() + * .expiresAt() * .owner() * .redactedValue() * .value() @@ -213,6 +243,7 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null + private var expiresAt: JsonField? = null private var object_: JsonValue = JsonValue.from("organization.admin_api_key") private var owner: JsonField? = null private var redactedValue: JsonField? = null @@ -225,6 +256,7 @@ private constructor( internal fun from(adminApiKeyCreateResponse: AdminApiKeyCreateResponse) = apply { id = adminApiKeyCreateResponse.id createdAt = adminApiKeyCreateResponse.createdAt + expiresAt = adminApiKeyCreateResponse.expiresAt object_ = adminApiKeyCreateResponse.object_ owner = adminApiKeyCreateResponse.owner redactedValue = adminApiKeyCreateResponse.redactedValue @@ -256,6 +288,27 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** The Unix timestamp (in seconds) of when the API key expires */ + fun expiresAt(expiresAt: Long?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** + * Alias for [Builder.expiresAt]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun expiresAt(expiresAt: Long) = expiresAt(expiresAt as Long?) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } + /** * Sets the field to an arbitrary JSON value. * @@ -369,6 +422,7 @@ private constructor( * ```java * .id() * .createdAt() + * .expiresAt() * .owner() * .redactedValue() * .value() @@ -380,6 +434,7 @@ private constructor( AdminApiKeyCreateResponse( checkRequired("id", id), checkRequired("createdAt", createdAt), + checkRequired("expiresAt", expiresAt), object_, checkRequired("owner", owner), checkRequired("redactedValue", redactedValue), @@ -407,6 +462,7 @@ private constructor( id() createdAt() + expiresAt() _object_().let { if (it != JsonValue.from("organization.admin_api_key")) { throw OpenAIInvalidDataException("'object_' is invalid, received $it") @@ -437,6 +493,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + object_.let { if (it == JsonValue.from("organization.admin_api_key")) 1 else 0 } + (owner.asKnown().getOrNull()?.validity() ?: 0) + (if (redactedValue.asKnown().isPresent) 1 else 0) + @@ -452,6 +509,7 @@ private constructor( return other is AdminApiKeyCreateResponse && id == other.id && createdAt == other.createdAt && + expiresAt == other.expiresAt && object_ == other.object_ && owner == other.owner && redactedValue == other.redactedValue && @@ -465,6 +523,7 @@ private constructor( Objects.hash( id, createdAt, + expiresAt, object_, owner, redactedValue, @@ -478,5 +537,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AdminApiKeyCreateResponse{id=$id, createdAt=$createdAt, object_=$object_, owner=$owner, redactedValue=$redactedValue, lastUsedAt=$lastUsedAt, name=$name, value=$value, additionalProperties=$additionalProperties}" + "AdminApiKeyCreateResponse{id=$id, createdAt=$createdAt, expiresAt=$expiresAt, object_=$object_, owner=$owner, redactedValue=$redactedValue, lastUsedAt=$lastUsedAt, name=$name, value=$value, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParams.kt index a0be53423..9f445f26f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParams.kt @@ -26,6 +26,7 @@ private constructor( private val limit: Long?, private val projectIds: List?, private val resourceIds: List?, + private val tenantOnly: Boolean?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -72,9 +73,20 @@ private constructor( /** Return only events for these projects. */ fun projectIds(): Optional> = Optional.ofNullable(projectIds) - /** Return only events performed on these targets. For example, a project ID updated. */ + /** + * Return only events performed on these targets. For example, a project ID updated. For ChatGPT + * connector role events, use the workspace connector resource ID shown in `details.id`, such as + * `__`. + */ fun resourceIds(): Optional> = Optional.ofNullable(resourceIds) + /** + * Return only tenant-scoped events associated with this organization. Required for + * tenant-scoped events such as `role.bound_to_resource` and `role.unbound_from_resource`. When + * `true`, all supplied event types must be tenant-scoped. + */ + fun tenantOnly(): Optional = Optional.ofNullable(tenantOnly) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -103,6 +115,7 @@ private constructor( private var limit: Long? = null private var projectIds: MutableList? = null private var resourceIds: MutableList? = null + private var tenantOnly: Boolean? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -117,6 +130,7 @@ private constructor( limit = auditLogListParams.limit projectIds = auditLogListParams.projectIds?.toMutableList() resourceIds = auditLogListParams.resourceIds?.toMutableList() + tenantOnly = auditLogListParams.tenantOnly additionalHeaders = auditLogListParams.additionalHeaders.toBuilder() additionalQueryParams = auditLogListParams.additionalQueryParams.toBuilder() } @@ -238,7 +252,11 @@ private constructor( projectIds = (projectIds ?: mutableListOf()).apply { add(projectId) } } - /** Return only events performed on these targets. For example, a project ID updated. */ + /** + * Return only events performed on these targets. For example, a project ID updated. For + * ChatGPT connector role events, use the workspace connector resource ID shown in + * `details.id`, such as `__`. + */ fun resourceIds(resourceIds: List?) = apply { this.resourceIds = resourceIds?.toMutableList() } @@ -255,6 +273,23 @@ private constructor( resourceIds = (resourceIds ?: mutableListOf()).apply { add(resourceId) } } + /** + * Return only tenant-scoped events associated with this organization. Required for + * tenant-scoped events such as `role.bound_to_resource` and `role.unbound_from_resource`. + * When `true`, all supplied event types must be tenant-scoped. + */ + fun tenantOnly(tenantOnly: Boolean?) = apply { this.tenantOnly = tenantOnly } + + /** + * Alias for [Builder.tenantOnly]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun tenantOnly(tenantOnly: Boolean) = tenantOnly(tenantOnly as Boolean?) + + /** Alias for calling [Builder.tenantOnly] with `tenantOnly.orElse(null)`. */ + fun tenantOnly(tenantOnly: Optional) = tenantOnly(tenantOnly.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -369,6 +404,7 @@ private constructor( limit, projectIds?.toImmutable(), resourceIds?.toImmutable(), + tenantOnly, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -398,6 +434,7 @@ private constructor( limit?.let { put("limit", it.toString()) } projectIds?.forEach { put("project_ids[]", it) } resourceIds?.forEach { put("resource_ids[]", it) } + tenantOnly?.let { put("tenant_only", it.toString()) } putAll(additionalQueryParams) } .build() @@ -719,6 +756,10 @@ private constructor( @JvmField val ROLE_ASSIGNMENT_DELETED = of("role.assignment.deleted") + @JvmField val ROLE_BOUND_TO_RESOURCE = of("role.bound_to_resource") + + @JvmField val ROLE_UNBOUND_FROM_RESOURCE = of("role.unbound_from_resource") + @JvmField val SCIM_ENABLED = of("scim.enabled") @JvmField val SCIM_DISABLED = of("scim.disabled") @@ -789,6 +830,8 @@ private constructor( ROLE_DELETED, ROLE_ASSIGNMENT_CREATED, ROLE_ASSIGNMENT_DELETED, + ROLE_BOUND_TO_RESOURCE, + ROLE_UNBOUND_FROM_RESOURCE, SCIM_ENABLED, SCIM_DISABLED, SERVICE_ACCOUNT_CREATED, @@ -858,6 +901,8 @@ private constructor( ROLE_DELETED, ROLE_ASSIGNMENT_CREATED, ROLE_ASSIGNMENT_DELETED, + ROLE_BOUND_TO_RESOURCE, + ROLE_UNBOUND_FROM_RESOURCE, SCIM_ENABLED, SCIM_DISABLED, SERVICE_ACCOUNT_CREATED, @@ -933,6 +978,8 @@ private constructor( ROLE_DELETED -> Value.ROLE_DELETED ROLE_ASSIGNMENT_CREATED -> Value.ROLE_ASSIGNMENT_CREATED ROLE_ASSIGNMENT_DELETED -> Value.ROLE_ASSIGNMENT_DELETED + ROLE_BOUND_TO_RESOURCE -> Value.ROLE_BOUND_TO_RESOURCE + ROLE_UNBOUND_FROM_RESOURCE -> Value.ROLE_UNBOUND_FROM_RESOURCE SCIM_ENABLED -> Value.SCIM_ENABLED SCIM_DISABLED -> Value.SCIM_DISABLED SERVICE_ACCOUNT_CREATED -> Value.SERVICE_ACCOUNT_CREATED @@ -1007,6 +1054,8 @@ private constructor( ROLE_DELETED -> Known.ROLE_DELETED ROLE_ASSIGNMENT_CREATED -> Known.ROLE_ASSIGNMENT_CREATED ROLE_ASSIGNMENT_DELETED -> Known.ROLE_ASSIGNMENT_DELETED + ROLE_BOUND_TO_RESOURCE -> Known.ROLE_BOUND_TO_RESOURCE + ROLE_UNBOUND_FROM_RESOURCE -> Known.ROLE_UNBOUND_FROM_RESOURCE SCIM_ENABLED -> Known.SCIM_ENABLED SCIM_DISABLED -> Known.SCIM_DISABLED SERVICE_ACCOUNT_CREATED -> Known.SERVICE_ACCOUNT_CREATED @@ -1094,6 +1143,7 @@ private constructor( limit == other.limit && projectIds == other.projectIds && resourceIds == other.resourceIds && + tenantOnly == other.tenantOnly && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } @@ -1109,10 +1159,11 @@ private constructor( limit, projectIds, resourceIds, + tenantOnly, additionalHeaders, additionalQueryParams, ) override fun toString() = - "AuditLogListParams{actorEmails=$actorEmails, actorIds=$actorIds, after=$after, before=$before, effectiveAt=$effectiveAt, eventTypes=$eventTypes, limit=$limit, projectIds=$projectIds, resourceIds=$resourceIds, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "AuditLogListParams{actorEmails=$actorEmails, actorIds=$actorIds, after=$after, before=$before, effectiveAt=$effectiveAt, eventTypes=$eventTypes, limit=$limit, projectIds=$projectIds, resourceIds=$resourceIds, tenantOnly=$tenantOnly, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponse.kt index 11f1eb208..81c8bf1e1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponse.kt @@ -65,8 +65,10 @@ private constructor( private val rateLimitUpdated: JsonField, private val roleAssignmentCreated: JsonField, private val roleAssignmentDeleted: JsonField, + private val roleBoundToResource: JsonField, private val roleCreated: JsonField, private val roleDeleted: JsonField, + private val roleUnboundFromResource: JsonField, private val roleUpdated: JsonField, private val scimDisabled: JsonField, private val scimEnabled: JsonField, @@ -205,12 +207,18 @@ private constructor( @JsonProperty("role.assignment.deleted") @ExcludeMissing roleAssignmentDeleted: JsonField = JsonMissing.of(), + @JsonProperty("role.bound_to_resource") + @ExcludeMissing + roleBoundToResource: JsonField = JsonMissing.of(), @JsonProperty("role.created") @ExcludeMissing roleCreated: JsonField = JsonMissing.of(), @JsonProperty("role.deleted") @ExcludeMissing roleDeleted: JsonField = JsonMissing.of(), + @JsonProperty("role.unbound_from_resource") + @ExcludeMissing + roleUnboundFromResource: JsonField = JsonMissing.of(), @JsonProperty("role.updated") @ExcludeMissing roleUpdated: JsonField = JsonMissing.of(), @@ -304,8 +312,10 @@ private constructor( rateLimitUpdated, roleAssignmentCreated, roleAssignmentDeleted, + roleBoundToResource, roleCreated, roleDeleted, + roleUnboundFromResource, roleUpdated, scimDisabled, scimEnabled, @@ -681,6 +691,15 @@ private constructor( fun roleAssignmentDeleted(): Optional = roleAssignmentDeleted.getOptional("role.assignment.deleted") + /** + * The details for events with this `type`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun roleBoundToResource(): Optional = + roleBoundToResource.getOptional("role.bound_to_resource") + /** * The details for events with this `type`. * @@ -697,6 +716,15 @@ private constructor( */ fun roleDeleted(): Optional = roleDeleted.getOptional("role.deleted") + /** + * The details for events with this `type`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun roleUnboundFromResource(): Optional = + roleUnboundFromResource.getOptional("role.unbound_from_resource") + /** * The details for events with this `type`. * @@ -1196,6 +1224,16 @@ private constructor( @ExcludeMissing fun _roleAssignmentDeleted(): JsonField = roleAssignmentDeleted + /** + * Returns the raw JSON value of [roleBoundToResource]. + * + * Unlike [roleBoundToResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("role.bound_to_resource") + @ExcludeMissing + fun _roleBoundToResource(): JsonField = roleBoundToResource + /** * Returns the raw JSON value of [roleCreated]. * @@ -1214,6 +1252,16 @@ private constructor( @ExcludeMissing fun _roleDeleted(): JsonField = roleDeleted + /** + * Returns the raw JSON value of [roleUnboundFromResource]. + * + * Unlike [roleUnboundFromResource], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("role.unbound_from_resource") + @ExcludeMissing + fun _roleUnboundFromResource(): JsonField = roleUnboundFromResource + /** * Returns the raw JSON value of [roleUpdated]. * @@ -1437,8 +1485,10 @@ private constructor( private var rateLimitUpdated: JsonField = JsonMissing.of() private var roleAssignmentCreated: JsonField = JsonMissing.of() private var roleAssignmentDeleted: JsonField = JsonMissing.of() + private var roleBoundToResource: JsonField = JsonMissing.of() private var roleCreated: JsonField = JsonMissing.of() private var roleDeleted: JsonField = JsonMissing.of() + private var roleUnboundFromResource: JsonField = JsonMissing.of() private var roleUpdated: JsonField = JsonMissing.of() private var scimDisabled: JsonField = JsonMissing.of() private var scimEnabled: JsonField = JsonMissing.of() @@ -1508,8 +1558,10 @@ private constructor( rateLimitUpdated = auditLogListResponse.rateLimitUpdated roleAssignmentCreated = auditLogListResponse.roleAssignmentCreated roleAssignmentDeleted = auditLogListResponse.roleAssignmentDeleted + roleBoundToResource = auditLogListResponse.roleBoundToResource roleCreated = auditLogListResponse.roleCreated roleDeleted = auditLogListResponse.roleDeleted + roleUnboundFromResource = auditLogListResponse.roleUnboundFromResource roleUpdated = auditLogListResponse.roleUpdated scimDisabled = auditLogListResponse.scimDisabled scimEnabled = auditLogListResponse.scimEnabled @@ -2107,6 +2159,21 @@ private constructor( this.roleAssignmentDeleted = roleAssignmentDeleted } + /** The details for events with this `type`. */ + fun roleBoundToResource(roleBoundToResource: RoleBoundToResource) = + roleBoundToResource(JsonField.of(roleBoundToResource)) + + /** + * Sets [Builder.roleBoundToResource] to an arbitrary JSON value. + * + * You should usually call [Builder.roleBoundToResource] with a well-typed + * [RoleBoundToResource] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun roleBoundToResource(roleBoundToResource: JsonField) = apply { + this.roleBoundToResource = roleBoundToResource + } + /** The details for events with this `type`. */ fun roleCreated(roleCreated: RoleCreated) = roleCreated(JsonField.of(roleCreated)) @@ -2135,6 +2202,22 @@ private constructor( this.roleDeleted = roleDeleted } + /** The details for events with this `type`. */ + fun roleUnboundFromResource(roleUnboundFromResource: RoleUnboundFromResource) = + roleUnboundFromResource(JsonField.of(roleUnboundFromResource)) + + /** + * Sets [Builder.roleUnboundFromResource] to an arbitrary JSON value. + * + * You should usually call [Builder.roleUnboundFromResource] with a well-typed + * [RoleUnboundFromResource] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun roleUnboundFromResource(roleUnboundFromResource: JsonField) = + apply { + this.roleUnboundFromResource = roleUnboundFromResource + } + /** The details for events with this `type`. */ fun roleUpdated(roleUpdated: RoleUpdated) = roleUpdated(JsonField.of(roleUpdated)) @@ -2452,8 +2535,10 @@ private constructor( rateLimitUpdated, roleAssignmentCreated, roleAssignmentDeleted, + roleBoundToResource, roleCreated, roleDeleted, + roleUnboundFromResource, roleUpdated, scimDisabled, scimEnabled, @@ -2527,8 +2612,10 @@ private constructor( rateLimitUpdated().ifPresent { it.validate() } roleAssignmentCreated().ifPresent { it.validate() } roleAssignmentDeleted().ifPresent { it.validate() } + roleBoundToResource().ifPresent { it.validate() } roleCreated().ifPresent { it.validate() } roleDeleted().ifPresent { it.validate() } + roleUnboundFromResource().ifPresent { it.validate() } roleUpdated().ifPresent { it.validate() } scimDisabled().ifPresent { it.validate() } scimEnabled().ifPresent { it.validate() } @@ -2601,8 +2688,10 @@ private constructor( (rateLimitUpdated.asKnown().getOrNull()?.validity() ?: 0) + (roleAssignmentCreated.asKnown().getOrNull()?.validity() ?: 0) + (roleAssignmentDeleted.asKnown().getOrNull()?.validity() ?: 0) + + (roleBoundToResource.asKnown().getOrNull()?.validity() ?: 0) + (roleCreated.asKnown().getOrNull()?.validity() ?: 0) + (roleDeleted.asKnown().getOrNull()?.validity() ?: 0) + + (roleUnboundFromResource.asKnown().getOrNull()?.validity() ?: 0) + (roleUpdated.asKnown().getOrNull()?.validity() ?: 0) + (scimDisabled.asKnown().getOrNull()?.validity() ?: 0) + (scimEnabled.asKnown().getOrNull()?.validity() ?: 0) + @@ -2741,6 +2830,10 @@ private constructor( @JvmField val ROLE_ASSIGNMENT_DELETED = of("role.assignment.deleted") + @JvmField val ROLE_BOUND_TO_RESOURCE = of("role.bound_to_resource") + + @JvmField val ROLE_UNBOUND_FROM_RESOURCE = of("role.unbound_from_resource") + @JvmField val SCIM_ENABLED = of("scim.enabled") @JvmField val SCIM_DISABLED = of("scim.disabled") @@ -2811,6 +2904,8 @@ private constructor( ROLE_DELETED, ROLE_ASSIGNMENT_CREATED, ROLE_ASSIGNMENT_DELETED, + ROLE_BOUND_TO_RESOURCE, + ROLE_UNBOUND_FROM_RESOURCE, SCIM_ENABLED, SCIM_DISABLED, SERVICE_ACCOUNT_CREATED, @@ -2880,6 +2975,8 @@ private constructor( ROLE_DELETED, ROLE_ASSIGNMENT_CREATED, ROLE_ASSIGNMENT_DELETED, + ROLE_BOUND_TO_RESOURCE, + ROLE_UNBOUND_FROM_RESOURCE, SCIM_ENABLED, SCIM_DISABLED, SERVICE_ACCOUNT_CREATED, @@ -2953,6 +3050,8 @@ private constructor( ROLE_DELETED -> Value.ROLE_DELETED ROLE_ASSIGNMENT_CREATED -> Value.ROLE_ASSIGNMENT_CREATED ROLE_ASSIGNMENT_DELETED -> Value.ROLE_ASSIGNMENT_DELETED + ROLE_BOUND_TO_RESOURCE -> Value.ROLE_BOUND_TO_RESOURCE + ROLE_UNBOUND_FROM_RESOURCE -> Value.ROLE_UNBOUND_FROM_RESOURCE SCIM_ENABLED -> Value.SCIM_ENABLED SCIM_DISABLED -> Value.SCIM_DISABLED SERVICE_ACCOUNT_CREATED -> Value.SERVICE_ACCOUNT_CREATED @@ -3027,6 +3126,8 @@ private constructor( ROLE_DELETED -> Known.ROLE_DELETED ROLE_ASSIGNMENT_CREATED -> Known.ROLE_ASSIGNMENT_CREATED ROLE_ASSIGNMENT_DELETED -> Known.ROLE_ASSIGNMENT_DELETED + ROLE_BOUND_TO_RESOURCE -> Known.ROLE_BOUND_TO_RESOURCE + ROLE_UNBOUND_FROM_RESOURCE -> Known.ROLE_UNBOUND_FROM_RESOURCE SCIM_ENABLED -> Known.SCIM_ENABLED SCIM_DISABLED -> Known.SCIM_DISABLED SERVICE_ACCOUNT_CREATED -> Known.SERVICE_ACCOUNT_CREATED @@ -14385,20 +14486,32 @@ private constructor( } /** The details for events with this `type`. */ - class RoleCreated + class RoleBoundToResource @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val connectorId: JsonField, + private val connectorName: JsonField, + private val enabled: JsonField, private val permissions: JsonField>, private val resourceId: JsonField, private val resourceType: JsonField, - private val roleName: JsonField, + private val roleId: JsonField, + private val source: JsonField, + private val workspaceId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("connector_id") + @ExcludeMissing + connectorId: JsonField = JsonMissing.of(), + @JsonProperty("connector_name") + @ExcludeMissing + connectorName: JsonField = JsonMissing.of(), + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), @JsonProperty("permissions") @ExcludeMissing permissions: JsonField> = JsonMissing.of(), @@ -14408,13 +14521,28 @@ private constructor( @JsonProperty("resource_type") @ExcludeMissing resourceType: JsonField = JsonMissing.of(), - @JsonProperty("role_name") + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("workspace_id") @ExcludeMissing - roleName: JsonField = JsonMissing.of(), - ) : this(id, permissions, resourceId, resourceType, roleName, mutableMapOf()) + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + connectorId, + connectorName, + enabled, + permissions, + resourceId, + resourceType, + roleId, + source, + workspaceId, + mutableMapOf(), + ) /** - * The role ID. + * The ID of the resource the role was bound to. ChatGPT workspace connector resources use + * `__`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14422,7 +14550,32 @@ private constructor( fun id(): Optional = id.getOptional("id") /** - * The permissions granted by the role. + * The connector ID for a ChatGPT workspace connector resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorId(): Optional = connectorId.getOptional("connector_id") + + /** + * The connector display name for a ChatGPT workspace connector resource, or the connector + * ID when the display name could not be resolved. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorName(): Optional = connectorName.getOptional("connector_name") + + /** + * Whether the connector is enabled for the role. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = enabled.getOptional("enabled") + + /** + * The permissions granted to the role for the resource. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14430,7 +14583,7 @@ private constructor( fun permissions(): Optional> = permissions.getOptional("permissions") /** - * The resource the role is scoped to. + * The ID of the resource the role was bound to. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14438,7 +14591,7 @@ private constructor( fun resourceId(): Optional = resourceId.getOptional("resource_id") /** - * The type of resource the role belongs to. + * The type of resource the role was bound to. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -14446,12 +14599,28 @@ private constructor( fun resourceType(): Optional = resourceType.getOptional("resource_type") /** - * The name of the role. + * The ID of the role that was bound to the resource. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun roleName(): Optional = roleName.getOptional("role_name") + fun roleId(): Optional = roleId.getOptional("role_id") + + /** + * The connector role mutation path that produced the event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The workspace ID for a ChatGPT workspace connector resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspace_id") /** * Returns the raw JSON value of [id]. @@ -14460,6 +14629,32 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [connectorId]. + * + * Unlike [connectorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("connector_id") + @ExcludeMissing + fun _connectorId(): JsonField = connectorId + + /** + * Returns the raw JSON value of [connectorName]. + * + * Unlike [connectorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connector_name") + @ExcludeMissing + fun _connectorName(): JsonField = connectorName + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + /** * Returns the raw JSON value of [permissions]. * @@ -14489,11 +14684,27 @@ private constructor( fun _resourceType(): JsonField = resourceType /** - * Returns the raw JSON value of [roleName]. + * Returns the raw JSON value of [roleId]. * - * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField = roleName + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_id") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -14509,31 +14720,44 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [RoleCreated]. */ + /** Returns a mutable builder for constructing an instance of [RoleBoundToResource]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RoleCreated]. */ + /** A builder for [RoleBoundToResource]. */ class Builder internal constructor() { private var id: JsonField = JsonMissing.of() + private var connectorId: JsonField = JsonMissing.of() + private var connectorName: JsonField = JsonMissing.of() + private var enabled: JsonField = JsonMissing.of() private var permissions: JsonField>? = null private var resourceId: JsonField = JsonMissing.of() private var resourceType: JsonField = JsonMissing.of() - private var roleName: JsonField = JsonMissing.of() + private var roleId: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleCreated: RoleCreated) = apply { - id = roleCreated.id - permissions = roleCreated.permissions.map { it.toMutableList() } - resourceId = roleCreated.resourceId - resourceType = roleCreated.resourceType - roleName = roleCreated.roleName - additionalProperties = roleCreated.additionalProperties.toMutableMap() + internal fun from(roleBoundToResource: RoleBoundToResource) = apply { + id = roleBoundToResource.id + connectorId = roleBoundToResource.connectorId + connectorName = roleBoundToResource.connectorName + enabled = roleBoundToResource.enabled + permissions = roleBoundToResource.permissions.map { it.toMutableList() } + resourceId = roleBoundToResource.resourceId + resourceType = roleBoundToResource.resourceType + roleId = roleBoundToResource.roleId + source = roleBoundToResource.source + workspaceId = roleBoundToResource.workspaceId + additionalProperties = roleBoundToResource.additionalProperties.toMutableMap() } - /** The role ID. */ + /** + * The ID of the resource the role was bound to. ChatGPT workspace connector resources + * use `__`. + */ fun id(id: String) = id(JsonField.of(id)) /** @@ -14545,7 +14769,50 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - /** The permissions granted by the role. */ + /** The connector ID for a ChatGPT workspace connector resource. */ + fun connectorId(connectorId: String) = connectorId(JsonField.of(connectorId)) + + /** + * Sets [Builder.connectorId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectorId(connectorId: JsonField) = apply { + this.connectorId = connectorId + } + + /** + * The connector display name for a ChatGPT workspace connector resource, or the + * connector ID when the display name could not be resolved. + */ + fun connectorName(connectorName: String) = connectorName(JsonField.of(connectorName)) + + /** + * Sets [Builder.connectorName] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectorName(connectorName: JsonField) = apply { + this.connectorName = connectorName + } + + /** Whether the connector is enabled for the role. */ + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** The permissions granted to the role for the resource. */ fun permissions(permissions: List) = permissions(JsonField.of(permissions)) /** @@ -14571,7 +14838,7 @@ private constructor( } } - /** The resource the role is scoped to. */ + /** The ID of the resource the role was bound to. */ fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) /** @@ -14583,7 +14850,7 @@ private constructor( */ fun resourceId(resourceId: JsonField) = apply { this.resourceId = resourceId } - /** The type of resource the role belongs to. */ + /** The type of resource the role was bound to. */ fun resourceType(resourceType: String) = resourceType(JsonField.of(resourceType)) /** @@ -14597,17 +14864,43 @@ private constructor( this.resourceType = resourceType } - /** The name of the role. */ - fun roleName(roleName: String) = roleName(JsonField.of(roleName)) + /** The ID of the role that was bound to the resource. */ + fun roleId(roleId: String) = roleId(JsonField.of(roleId)) /** - * Sets [Builder.roleName] to an arbitrary JSON value. + * Sets [Builder.roleId] to an arbitrary JSON value. * - * You should usually call [Builder.roleName] with a well-typed [String] value instead. + * You should usually call [Builder.roleId] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun roleName(roleName: JsonField) = apply { this.roleName = roleName } + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + /** The connector role mutation path that produced the event. */ + fun source(source: Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The workspace ID for a ChatGPT workspace connector resource. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -14629,17 +14922,22 @@ private constructor( } /** - * Returns an immutable instance of [RoleCreated]. + * Returns an immutable instance of [RoleBoundToResource]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): RoleCreated = - RoleCreated( + fun build(): RoleBoundToResource = + RoleBoundToResource( id, + connectorId, + connectorName, + enabled, (permissions ?: JsonMissing.of()).map { it.toImmutable() }, resourceId, resourceType, - roleName, + roleId, + source, + workspaceId, additionalProperties.toMutableMap(), ) } @@ -14655,16 +14953,21 @@ private constructor( * @throws OpenAIInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): RoleCreated = apply { + fun validate(): RoleBoundToResource = apply { if (validated) { return@apply } id() + connectorId() + connectorName() + enabled() permissions() resourceId() resourceType() - roleName() + roleId() + source().ifPresent { it.validate() } + workspaceId() validated = true } @@ -14685,94 +14988,970 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (connectorId.asKnown().isPresent) 1 else 0) + + (if (connectorName.asKnown().isPresent) 1 else 0) + + (if (enabled.asKnown().isPresent) 1 else 0) + (permissions.asKnown().getOrNull()?.size ?: 0) + (if (resourceId.asKnown().isPresent) 1 else 0) + (if (resourceType.asKnown().isPresent) 1 else 0) + - (if (roleName.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + (if (roleId.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) - return other is RoleCreated && - id == other.id && - permissions == other.permissions && - resourceId == other.resourceId && - resourceType == other.resourceType && - roleName == other.roleName && - additionalProperties == other.additionalProperties - } + /** The connector role mutation path that produced the event. */ + class Source @JsonCreator private constructor(private val value: JsonField) : Enum { - private val hashCode: Int by lazy { - Objects.hash(id, permissions, resourceId, resourceType, roleName, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RoleCreated{id=$id, permissions=$permissions, resourceId=$resourceId, resourceType=$resourceType, roleName=$roleName, additionalProperties=$additionalProperties}" - } + /** + * 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 - /** The details for events with this `type`. */ - class RoleDeleted - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + companion object { - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + @JvmField val ROLE_TOGGLE = of("role_toggle") - /** - * The role ID. - * - * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") + @JvmField val ROLE_CONNECTOR_UPDATE = of("role_connector_update") - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + @JvmField val ROLE_DELETE = of("role_delete") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val WORKSPACE_PERMISSIONS = of("workspace_permissions") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val CONNECTOR_PUBLISH = of("connector_publish") - fun toBuilder() = Builder().from(this) + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } - companion object { + /** An enum containing [Source]'s known values. */ + enum class Known { + ROLE_TOGGLE, + ROLE_CONNECTOR_UPDATE, + ROLE_DELETE, + WORKSPACE_PERMISSIONS, + CONNECTOR_PUBLISH, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + ROLE_TOGGLE, + ROLE_CONNECTOR_UPDATE, + ROLE_DELETE, + WORKSPACE_PERMISSIONS, + CONNECTOR_PUBLISH, + /** + * An enum member indicating that [Source] 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) { + ROLE_TOGGLE -> Value.ROLE_TOGGLE + ROLE_CONNECTOR_UPDATE -> Value.ROLE_CONNECTOR_UPDATE + ROLE_DELETE -> Value.ROLE_DELETE + WORKSPACE_PERMISSIONS -> Value.WORKSPACE_PERMISSIONS + CONNECTOR_PUBLISH -> Value.CONNECTOR_PUBLISH + 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) { + ROLE_TOGGLE -> Known.ROLE_TOGGLE + ROLE_CONNECTOR_UPDATE -> Known.ROLE_CONNECTOR_UPDATE + ROLE_DELETE -> Known.ROLE_DELETE + WORKSPACE_PERMISSIONS -> Known.WORKSPACE_PERMISSIONS + CONNECTOR_PUBLISH -> Known.CONNECTOR_PUBLISH + else -> throw OpenAIInvalidDataException("Unknown Source: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Source = 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 Source && 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 RoleBoundToResource && + id == other.id && + connectorId == other.connectorId && + connectorName == other.connectorName && + enabled == other.enabled && + permissions == other.permissions && + resourceId == other.resourceId && + resourceType == other.resourceType && + roleId == other.roleId && + source == other.source && + workspaceId == other.workspaceId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + connectorId, + connectorName, + enabled, + permissions, + resourceId, + resourceType, + roleId, + source, + workspaceId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoleBoundToResource{id=$id, connectorId=$connectorId, connectorName=$connectorName, enabled=$enabled, permissions=$permissions, resourceId=$resourceId, resourceType=$resourceType, roleId=$roleId, source=$source, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" + } + + /** The details for events with this `type`. */ + class RoleCreated + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val permissions: JsonField>, + private val resourceId: JsonField, + private val resourceType: JsonField, + private val roleName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField> = JsonMissing.of(), + @JsonProperty("resource_id") + @ExcludeMissing + resourceId: JsonField = JsonMissing.of(), + @JsonProperty("resource_type") + @ExcludeMissing + resourceType: JsonField = JsonMissing.of(), + @JsonProperty("role_name") + @ExcludeMissing + roleName: JsonField = JsonMissing.of(), + ) : this(id, permissions, resourceId, resourceType, roleName, mutableMapOf()) + + /** + * The role ID. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * The permissions granted by the role. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional> = permissions.getOptional("permissions") + + /** + * The resource the role is scoped to. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resourceId(): Optional = resourceId.getOptional("resource_id") + + /** + * The type of resource the role belongs to. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resourceType(): Optional = resourceType.getOptional("resource_type") + + /** + * The name of the role. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun roleName(): Optional = roleName.getOptional("role_name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField> = permissions + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_id") + @ExcludeMissing + fun _resourceId(): JsonField = resourceId + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resource_type") + @ExcludeMissing + fun _resourceType(): JsonField = resourceType + + /** + * Returns the raw JSON value of [roleName]. + * + * Unlike [roleName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_name") @ExcludeMissing fun _roleName(): JsonField = roleName + + @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 [RoleCreated]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleCreated]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var permissions: JsonField>? = null + private var resourceId: JsonField = JsonMissing.of() + private var resourceType: JsonField = JsonMissing.of() + private var roleName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(roleCreated: RoleCreated) = apply { + id = roleCreated.id + permissions = roleCreated.permissions.map { it.toMutableList() } + resourceId = roleCreated.resourceId + resourceType = roleCreated.resourceType + roleName = roleCreated.roleName + additionalProperties = roleCreated.additionalProperties.toMutableMap() + } + + /** The role ID. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The permissions granted by the role. */ + fun permissions(permissions: List) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + /** The resource the role is scoped to. */ + fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceId(resourceId: JsonField) = apply { this.resourceId = resourceId } + + /** The type of resource the role belongs to. */ + fun resourceType(resourceType: String) = resourceType(JsonField.of(resourceType)) + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceType(resourceType: JsonField) = apply { + this.resourceType = resourceType + } + + /** The name of the role. */ + fun roleName(roleName: String) = roleName(JsonField.of(roleName)) + + /** + * Sets [Builder.roleName] to an arbitrary JSON value. + * + * You should usually call [Builder.roleName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleName(roleName: JsonField) = apply { this.roleName = roleName } + + 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 [RoleCreated]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoleCreated = + RoleCreated( + id, + (permissions ?: JsonMissing.of()).map { it.toImmutable() }, + resourceId, + resourceType, + roleName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RoleCreated = apply { + if (validated) { + return@apply + } + + id() + permissions() + resourceId() + resourceType() + roleName() + 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 (id.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + (if (resourceId.asKnown().isPresent) 1 else 0) + + (if (resourceType.asKnown().isPresent) 1 else 0) + + (if (roleName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleCreated && + id == other.id && + permissions == other.permissions && + resourceId == other.resourceId && + resourceType == other.resourceType && + roleName == other.roleName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, permissions, resourceId, resourceType, roleName, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoleCreated{id=$id, permissions=$permissions, resourceId=$resourceId, resourceType=$resourceType, roleName=$roleName, additionalProperties=$additionalProperties}" + } + + /** The details for events with this `type`. */ + class RoleDeleted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) + + /** + * The role ID. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @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 [RoleDeleted]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [RoleDeleted]. */ + /** A builder for [RoleDeleted]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(roleDeleted: RoleDeleted) = apply { + id = roleDeleted.id + additionalProperties = roleDeleted.additionalProperties.toMutableMap() + } + + /** The role ID. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun 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 [RoleDeleted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RoleDeleted = RoleDeleted(id, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): RoleDeleted = apply { + if (validated) { + return@apply + } + + id() + 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 (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoleDeleted && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RoleDeleted{id=$id, additionalProperties=$additionalProperties}" + } + + /** The details for events with this `type`. */ + class RoleUnboundFromResource + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val connectorId: JsonField, + private val connectorName: JsonField, + private val enabled: JsonField, + private val permissions: JsonField>, + private val resourceId: JsonField, + private val resourceType: JsonField, + private val roleId: JsonField, + private val source: JsonField, + private val workspaceId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("connector_id") + @ExcludeMissing + connectorId: JsonField = JsonMissing.of(), + @JsonProperty("connector_name") + @ExcludeMissing + connectorName: JsonField = JsonMissing.of(), + @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("permissions") + @ExcludeMissing + permissions: JsonField> = JsonMissing.of(), + @JsonProperty("resource_id") + @ExcludeMissing + resourceId: JsonField = JsonMissing.of(), + @JsonProperty("resource_type") + @ExcludeMissing + resourceType: JsonField = JsonMissing.of(), + @JsonProperty("role_id") @ExcludeMissing roleId: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("workspace_id") + @ExcludeMissing + workspaceId: JsonField = JsonMissing.of(), + ) : this( + id, + connectorId, + connectorName, + enabled, + permissions, + resourceId, + resourceType, + roleId, + source, + workspaceId, + mutableMapOf(), + ) + + /** + * The ID of the resource the role was unbound from. ChatGPT workspace connector resources + * use `__`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * The connector ID for a ChatGPT workspace connector resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorId(): Optional = connectorId.getOptional("connector_id") + + /** + * The connector display name for a ChatGPT workspace connector resource, or the connector + * ID when the display name could not be resolved. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorName(): Optional = connectorName.getOptional("connector_name") + + /** + * Whether the connector is enabled for the role. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabled(): Optional = enabled.getOptional("enabled") + + /** + * The permissions remaining for the role after the change. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun permissions(): Optional> = permissions.getOptional("permissions") + + /** + * The ID of the resource the role was unbound from. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resourceId(): Optional = resourceId.getOptional("resource_id") + + /** + * The type of resource the role was unbound from. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resourceType(): Optional = resourceType.getOptional("resource_type") + + /** + * The ID of the role that was unbound from the resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun roleId(): Optional = roleId.getOptional("role_id") + + /** + * The connector role mutation path that produced the event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * The workspace ID for a ChatGPT workspace connector resource. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun workspaceId(): Optional = workspaceId.getOptional("workspace_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [connectorId]. + * + * Unlike [connectorId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("connector_id") + @ExcludeMissing + fun _connectorId(): JsonField = connectorId + + /** + * Returns the raw JSON value of [connectorName]. + * + * Unlike [connectorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connector_name") + @ExcludeMissing + fun _connectorName(): JsonField = connectorName + + /** + * Returns the raw JSON value of [enabled]. + * + * Unlike [enabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + + /** + * Returns the raw JSON value of [permissions]. + * + * Unlike [permissions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("permissions") + @ExcludeMissing + fun _permissions(): JsonField> = permissions + + /** + * Returns the raw JSON value of [resourceId]. + * + * Unlike [resourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resource_id") + @ExcludeMissing + fun _resourceId(): JsonField = resourceId + + /** + * Returns the raw JSON value of [resourceType]. + * + * Unlike [resourceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resource_type") + @ExcludeMissing + fun _resourceType(): JsonField = resourceType + + /** + * Returns the raw JSON value of [roleId]. + * + * Unlike [roleId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("role_id") @ExcludeMissing fun _roleId(): JsonField = roleId + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [workspaceId]. + * + * Unlike [workspaceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("workspace_id") + @ExcludeMissing + fun _workspaceId(): JsonField = workspaceId + + @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 [RoleUnboundFromResource]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoleUnboundFromResource]. */ class Builder internal constructor() { private var id: JsonField = JsonMissing.of() + private var connectorId: JsonField = JsonMissing.of() + private var connectorName: JsonField = JsonMissing.of() + private var enabled: JsonField = JsonMissing.of() + private var permissions: JsonField>? = null + private var resourceId: JsonField = JsonMissing.of() + private var resourceType: JsonField = JsonMissing.of() + private var roleId: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var workspaceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(roleDeleted: RoleDeleted) = apply { - id = roleDeleted.id - additionalProperties = roleDeleted.additionalProperties.toMutableMap() + internal fun from(roleUnboundFromResource: RoleUnboundFromResource) = apply { + id = roleUnboundFromResource.id + connectorId = roleUnboundFromResource.connectorId + connectorName = roleUnboundFromResource.connectorName + enabled = roleUnboundFromResource.enabled + permissions = roleUnboundFromResource.permissions.map { it.toMutableList() } + resourceId = roleUnboundFromResource.resourceId + resourceType = roleUnboundFromResource.resourceType + roleId = roleUnboundFromResource.roleId + source = roleUnboundFromResource.source + workspaceId = roleUnboundFromResource.workspaceId + additionalProperties = roleUnboundFromResource.additionalProperties.toMutableMap() } - /** The role ID. */ + /** + * The ID of the resource the role was unbound from. ChatGPT workspace connector + * resources use `__`. + */ fun id(id: String) = id(JsonField.of(id)) /** @@ -14784,6 +15963,139 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** The connector ID for a ChatGPT workspace connector resource. */ + fun connectorId(connectorId: String) = connectorId(JsonField.of(connectorId)) + + /** + * Sets [Builder.connectorId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectorId(connectorId: JsonField) = apply { + this.connectorId = connectorId + } + + /** + * The connector display name for a ChatGPT workspace connector resource, or the + * connector ID when the display name could not be resolved. + */ + fun connectorName(connectorName: String) = connectorName(JsonField.of(connectorName)) + + /** + * Sets [Builder.connectorName] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectorName(connectorName: JsonField) = apply { + this.connectorName = connectorName + } + + /** Whether the connector is enabled for the role. */ + fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + + /** + * Sets [Builder.enabled] to an arbitrary JSON value. + * + * You should usually call [Builder.enabled] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + + /** The permissions remaining for the role after the change. */ + fun permissions(permissions: List) = permissions(JsonField.of(permissions)) + + /** + * Sets [Builder.permissions] to an arbitrary JSON value. + * + * You should usually call [Builder.permissions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun permissions(permissions: JsonField>) = apply { + this.permissions = permissions.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [permissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPermission(permission: String) = apply { + permissions = + (permissions ?: JsonField.of(mutableListOf())).also { + checkKnown("permissions", it).add(permission) + } + } + + /** The ID of the resource the role was unbound from. */ + fun resourceId(resourceId: String) = resourceId(JsonField.of(resourceId)) + + /** + * Sets [Builder.resourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceId(resourceId: JsonField) = apply { this.resourceId = resourceId } + + /** The type of resource the role was unbound from. */ + fun resourceType(resourceType: String) = resourceType(JsonField.of(resourceType)) + + /** + * Sets [Builder.resourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.resourceType] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resourceType(resourceType: JsonField) = apply { + this.resourceType = resourceType + } + + /** The ID of the role that was unbound from the resource. */ + fun roleId(roleId: String) = roleId(JsonField.of(roleId)) + + /** + * Sets [Builder.roleId] to an arbitrary JSON value. + * + * You should usually call [Builder.roleId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun roleId(roleId: JsonField) = apply { this.roleId = roleId } + + /** The connector role mutation path that produced the event. */ + fun source(source: Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The workspace ID for a ChatGPT workspace connector resource. */ + fun workspaceId(workspaceId: String) = workspaceId(JsonField.of(workspaceId)) + + /** + * Sets [Builder.workspaceId] to an arbitrary JSON value. + * + * You should usually call [Builder.workspaceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun workspaceId(workspaceId: JsonField) = apply { + this.workspaceId = workspaceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -14804,11 +16116,24 @@ private constructor( } /** - * Returns an immutable instance of [RoleDeleted]. + * Returns an immutable instance of [RoleUnboundFromResource]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): RoleDeleted = RoleDeleted(id, additionalProperties.toMutableMap()) + fun build(): RoleUnboundFromResource = + RoleUnboundFromResource( + id, + connectorId, + connectorName, + enabled, + (permissions ?: JsonMissing.of()).map { it.toImmutable() }, + resourceId, + resourceType, + roleId, + source, + workspaceId, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -14822,12 +16147,21 @@ private constructor( * @throws OpenAIInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): RoleDeleted = apply { + fun validate(): RoleUnboundFromResource = apply { if (validated) { return@apply } id() + connectorId() + connectorName() + enabled() + permissions() + resourceId() + resourceType() + roleId() + source().ifPresent { it.validate() } + workspaceId() validated = true } @@ -14845,23 +16179,216 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (connectorId.asKnown().isPresent) 1 else 0) + + (if (connectorName.asKnown().isPresent) 1 else 0) + + (if (enabled.asKnown().isPresent) 1 else 0) + + (permissions.asKnown().getOrNull()?.size ?: 0) + + (if (resourceId.asKnown().isPresent) 1 else 0) + + (if (resourceType.asKnown().isPresent) 1 else 0) + + (if (roleId.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (if (workspaceId.asKnown().isPresent) 1 else 0) + + /** The connector role mutation path that produced the event. */ + class Source @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 ROLE_TOGGLE = of("role_toggle") + + @JvmField val ROLE_CONNECTOR_UPDATE = of("role_connector_update") + + @JvmField val ROLE_DELETE = of("role_delete") + + @JvmField val WORKSPACE_PERMISSIONS = of("workspace_permissions") + + @JvmField val CONNECTOR_PUBLISH = of("connector_publish") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + ROLE_TOGGLE, + ROLE_CONNECTOR_UPDATE, + ROLE_DELETE, + WORKSPACE_PERMISSIONS, + CONNECTOR_PUBLISH, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] 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 { + ROLE_TOGGLE, + ROLE_CONNECTOR_UPDATE, + ROLE_DELETE, + WORKSPACE_PERMISSIONS, + CONNECTOR_PUBLISH, + /** + * An enum member indicating that [Source] 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) { + ROLE_TOGGLE -> Value.ROLE_TOGGLE + ROLE_CONNECTOR_UPDATE -> Value.ROLE_CONNECTOR_UPDATE + ROLE_DELETE -> Value.ROLE_DELETE + WORKSPACE_PERMISSIONS -> Value.WORKSPACE_PERMISSIONS + CONNECTOR_PUBLISH -> Value.CONNECTOR_PUBLISH + 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) { + ROLE_TOGGLE -> Known.ROLE_TOGGLE + ROLE_CONNECTOR_UPDATE -> Known.ROLE_CONNECTOR_UPDATE + ROLE_DELETE -> Known.ROLE_DELETE + WORKSPACE_PERMISSIONS -> Known.WORKSPACE_PERMISSIONS + CONNECTOR_PUBLISH -> Known.CONNECTOR_PUBLISH + else -> throw OpenAIInvalidDataException("Unknown Source: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws OpenAIInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Source = 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 Source && 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 RoleDeleted && + return other is RoleUnboundFromResource && id == other.id && + connectorId == other.connectorId && + connectorName == other.connectorName && + enabled == other.enabled && + permissions == other.permissions && + resourceId == other.resourceId && + resourceType == other.resourceType && + roleId == other.roleId && + source == other.source && + workspaceId == other.workspaceId && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + id, + connectorId, + connectorName, + enabled, + permissions, + resourceId, + resourceType, + roleId, + source, + workspaceId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode - override fun toString() = "RoleDeleted{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = + "RoleUnboundFromResource{id=$id, connectorId=$connectorId, connectorName=$connectorName, enabled=$enabled, permissions=$permissions, resourceId=$resourceId, resourceType=$resourceType, roleId=$roleId, source=$source, workspaceId=$workspaceId, additionalProperties=$additionalProperties}" } /** The details for events with this `type`. */ @@ -18858,8 +20385,10 @@ private constructor( rateLimitUpdated == other.rateLimitUpdated && roleAssignmentCreated == other.roleAssignmentCreated && roleAssignmentDeleted == other.roleAssignmentDeleted && + roleBoundToResource == other.roleBoundToResource && roleCreated == other.roleCreated && roleDeleted == other.roleDeleted && + roleUnboundFromResource == other.roleUnboundFromResource && roleUpdated == other.roleUpdated && scimDisabled == other.scimDisabled && scimEnabled == other.scimEnabled && @@ -18924,8 +20453,10 @@ private constructor( rateLimitUpdated, roleAssignmentCreated, roleAssignmentDeleted, + roleBoundToResource, roleCreated, roleDeleted, + roleUnboundFromResource, roleUpdated, scimDisabled, scimEnabled, @@ -18948,5 +20479,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AuditLogListResponse{id=$id, effectiveAt=$effectiveAt, type=$type, actor=$actor, apiKeyCreated=$apiKeyCreated, apiKeyDeleted=$apiKeyDeleted, apiKeyUpdated=$apiKeyUpdated, certificateCreated=$certificateCreated, certificateDeleted=$certificateDeleted, certificateUpdated=$certificateUpdated, certificatesActivated=$certificatesActivated, certificatesDeactivated=$certificatesDeactivated, checkpointPermissionCreated=$checkpointPermissionCreated, checkpointPermissionDeleted=$checkpointPermissionDeleted, externalKeyRegistered=$externalKeyRegistered, externalKeyRemoved=$externalKeyRemoved, groupCreated=$groupCreated, groupDeleted=$groupDeleted, groupUpdated=$groupUpdated, inviteAccepted=$inviteAccepted, inviteDeleted=$inviteDeleted, inviteSent=$inviteSent, ipAllowlistConfigActivated=$ipAllowlistConfigActivated, ipAllowlistConfigDeactivated=$ipAllowlistConfigDeactivated, ipAllowlistCreated=$ipAllowlistCreated, ipAllowlistDeleted=$ipAllowlistDeleted, ipAllowlistUpdated=$ipAllowlistUpdated, loginFailed=$loginFailed, loginSucceeded=$loginSucceeded, logoutFailed=$logoutFailed, logoutSucceeded=$logoutSucceeded, organizationUpdated=$organizationUpdated, project=$project, projectArchived=$projectArchived, projectCreated=$projectCreated, projectDeleted=$projectDeleted, projectUpdated=$projectUpdated, rateLimitDeleted=$rateLimitDeleted, rateLimitUpdated=$rateLimitUpdated, roleAssignmentCreated=$roleAssignmentCreated, roleAssignmentDeleted=$roleAssignmentDeleted, roleCreated=$roleCreated, roleDeleted=$roleDeleted, roleUpdated=$roleUpdated, scimDisabled=$scimDisabled, scimEnabled=$scimEnabled, serviceAccountCreated=$serviceAccountCreated, serviceAccountDeleted=$serviceAccountDeleted, serviceAccountUpdated=$serviceAccountUpdated, userAdded=$userAdded, userDeleted=$userDeleted, userUpdated=$userUpdated, workloadIdentityProviderMappingCreated=$workloadIdentityProviderMappingCreated, workloadIdentityProviderMappingDeleted=$workloadIdentityProviderMappingDeleted, workloadIdentityProviderMappingUpdated=$workloadIdentityProviderMappingUpdated, workloadIdentityProviderCreated=$workloadIdentityProviderCreated, workloadIdentityProviderDeleted=$workloadIdentityProviderDeleted, workloadIdentityProviderUpdated=$workloadIdentityProviderUpdated, additionalProperties=$additionalProperties}" + "AuditLogListResponse{id=$id, effectiveAt=$effectiveAt, type=$type, actor=$actor, apiKeyCreated=$apiKeyCreated, apiKeyDeleted=$apiKeyDeleted, apiKeyUpdated=$apiKeyUpdated, certificateCreated=$certificateCreated, certificateDeleted=$certificateDeleted, certificateUpdated=$certificateUpdated, certificatesActivated=$certificatesActivated, certificatesDeactivated=$certificatesDeactivated, checkpointPermissionCreated=$checkpointPermissionCreated, checkpointPermissionDeleted=$checkpointPermissionDeleted, externalKeyRegistered=$externalKeyRegistered, externalKeyRemoved=$externalKeyRemoved, groupCreated=$groupCreated, groupDeleted=$groupDeleted, groupUpdated=$groupUpdated, inviteAccepted=$inviteAccepted, inviteDeleted=$inviteDeleted, inviteSent=$inviteSent, ipAllowlistConfigActivated=$ipAllowlistConfigActivated, ipAllowlistConfigDeactivated=$ipAllowlistConfigDeactivated, ipAllowlistCreated=$ipAllowlistCreated, ipAllowlistDeleted=$ipAllowlistDeleted, ipAllowlistUpdated=$ipAllowlistUpdated, loginFailed=$loginFailed, loginSucceeded=$loginSucceeded, logoutFailed=$logoutFailed, logoutSucceeded=$logoutSucceeded, organizationUpdated=$organizationUpdated, project=$project, projectArchived=$projectArchived, projectCreated=$projectCreated, projectDeleted=$projectDeleted, projectUpdated=$projectUpdated, rateLimitDeleted=$rateLimitDeleted, rateLimitUpdated=$rateLimitUpdated, roleAssignmentCreated=$roleAssignmentCreated, roleAssignmentDeleted=$roleAssignmentDeleted, roleBoundToResource=$roleBoundToResource, roleCreated=$roleCreated, roleDeleted=$roleDeleted, roleUnboundFromResource=$roleUnboundFromResource, roleUpdated=$roleUpdated, scimDisabled=$scimDisabled, scimEnabled=$scimEnabled, serviceAccountCreated=$serviceAccountCreated, serviceAccountDeleted=$serviceAccountDeleted, serviceAccountUpdated=$serviceAccountUpdated, userAdded=$userAdded, userDeleted=$userDeleted, userUpdated=$userUpdated, workloadIdentityProviderMappingCreated=$workloadIdentityProviderMappingCreated, workloadIdentityProviderMappingDeleted=$workloadIdentityProviderMappingDeleted, workloadIdentityProviderMappingUpdated=$workloadIdentityProviderMappingUpdated, workloadIdentityProviderCreated=$workloadIdentityProviderCreated, workloadIdentityProviderDeleted=$workloadIdentityProviderDeleted, workloadIdentityProviderUpdated=$workloadIdentityProviderUpdated, additionalProperties=$additionalProperties}" } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/spendalerts/SpendAlertRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/spendalerts/SpendAlertRetrieveParams.kt new file mode 100644 index 000000000..5555ec0dc --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/spendalerts/SpendAlertRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.admin.organization.projects.spendalerts + +import com.openai.core.Params +import com.openai.core.checkRequired +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieves a project spend alert. */ +class SpendAlertRetrieveParams +private constructor( + private val projectId: String, + private val alertId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun projectId(): String = projectId + + fun alertId(): Optional = Optional.ofNullable(alertId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SpendAlertRetrieveParams]. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpendAlertRetrieveParams]. */ + class Builder internal constructor() { + + private var projectId: String? = null + private var alertId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(spendAlertRetrieveParams: SpendAlertRetrieveParams) = apply { + projectId = spendAlertRetrieveParams.projectId + alertId = spendAlertRetrieveParams.alertId + additionalHeaders = spendAlertRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = spendAlertRetrieveParams.additionalQueryParams.toBuilder() + } + + fun projectId(projectId: String) = apply { this.projectId = projectId } + + fun alertId(alertId: String?) = apply { this.alertId = alertId } + + /** Alias for calling [Builder.alertId] with `alertId.orElse(null)`. */ + fun alertId(alertId: Optional) = alertId(alertId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SpendAlertRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SpendAlertRetrieveParams = + SpendAlertRetrieveParams( + checkRequired("projectId", projectId), + alertId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> projectId + 1 -> alertId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendAlertRetrieveParams && + projectId == other.projectId && + alertId == other.alertId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(projectId, alertId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SpendAlertRetrieveParams{projectId=$projectId, alertId=$alertId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/spendalerts/SpendAlertRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/spendalerts/SpendAlertRetrieveParams.kt new file mode 100644 index 000000000..25c09f51a --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/spendalerts/SpendAlertRetrieveParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.admin.organization.spendalerts + +import com.openai.core.Params +import com.openai.core.http.Headers +import com.openai.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieves an organization spend alert. */ +class SpendAlertRetrieveParams +private constructor( + private val alertId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun alertId(): Optional = Optional.ofNullable(alertId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SpendAlertRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SpendAlertRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SpendAlertRetrieveParams]. */ + class Builder internal constructor() { + + private var alertId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(spendAlertRetrieveParams: SpendAlertRetrieveParams) = apply { + alertId = spendAlertRetrieveParams.alertId + additionalHeaders = spendAlertRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = spendAlertRetrieveParams.additionalQueryParams.toBuilder() + } + + fun alertId(alertId: String?) = apply { this.alertId = alertId } + + /** Alias for calling [Builder.alertId] with `alertId.orElse(null)`. */ + fun alertId(alertId: Optional) = alertId(alertId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SpendAlertRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SpendAlertRetrieveParams = + SpendAlertRetrieveParams( + alertId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> alertId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SpendAlertRetrieveParams && + alertId == other.alertId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(alertId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SpendAlertRetrieveParams{alertId=$alertId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt index 7281455d8..ea90af07c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponseCreateParams.kt @@ -382,7 +382,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun truncation(): Optional = body.truncation() + @Deprecated("deprecated") fun truncation(): Optional = body.truncation() /** * This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use @@ -595,7 +595,7 @@ private constructor( * * Unlike [truncation], this method doesn't throw if the JSON field has an unexpected type. */ - fun _truncation(): JsonField = body._truncation() + @Deprecated("deprecated") fun _truncation(): JsonField = body._truncation() /** * Returns the raw JSON value of [user]. @@ -1527,9 +1527,11 @@ private constructor( * - `disabled` (default): If the input size will exceed the context window size for a * model, the request will fail with a 400 error. */ + @Deprecated("deprecated") fun truncation(truncation: Truncation?) = apply { body.truncation(truncation) } /** Alias for calling [Builder.truncation] with `truncation.orElse(null)`. */ + @Deprecated("deprecated") fun truncation(truncation: Optional) = truncation(truncation.getOrNull()) /** @@ -1539,6 +1541,7 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ + @Deprecated("deprecated") fun truncation(truncation: JsonField) = apply { body.truncation(truncation) } /** @@ -2173,6 +2176,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ + @Deprecated("deprecated") fun truncation(): Optional = truncation.getOptional("truncation") /** @@ -2430,6 +2434,7 @@ private constructor( * * Unlike [truncation], this method doesn't throw if the JSON field has an unexpected type. */ + @Deprecated("deprecated") @JsonProperty("truncation") @ExcludeMissing fun _truncation(): JsonField = truncation @@ -3393,9 +3398,11 @@ private constructor( * - `disabled` (default): If the input size will exceed the context window size for a * model, the request will fail with a 400 error. */ + @Deprecated("deprecated") fun truncation(truncation: Truncation?) = truncation(JsonField.ofNullable(truncation)) /** Alias for calling [Builder.truncation] with `truncation.orElse(null)`. */ + @Deprecated("deprecated") fun truncation(truncation: Optional) = truncation(truncation.getOrNull()) /** @@ -3405,6 +3412,7 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ + @Deprecated("deprecated") fun truncation(truncation: JsonField) = apply { this.truncation = truncation } @@ -5595,6 +5603,7 @@ private constructor( * - `disabled` (default): If the input size will exceed the context window size for a model, * the request will fail with a 400 error. */ + @Deprecated("deprecated") class Truncation @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt index 87f102301..ca991f7a1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/ResponsesClientEvent.kt @@ -538,6 +538,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ + @Deprecated("deprecated") fun truncation(): Optional = truncation.getOptional("truncation") /** @@ -788,6 +789,7 @@ private constructor( * * Unlike [truncation], this method doesn't throw if the JSON field has an unexpected type. */ + @Deprecated("deprecated") @JsonProperty("truncation") @ExcludeMissing fun _truncation(): JsonField = truncation @@ -1765,9 +1767,11 @@ private constructor( * - `disabled` (default): If the input size will exceed the context window size for a * model, the request will fail with a 400 error. */ + @Deprecated("deprecated") fun truncation(truncation: Truncation?) = truncation(JsonField.ofNullable(truncation)) /** Alias for calling [Builder.truncation] with `truncation.orElse(null)`. */ + @Deprecated("deprecated") fun truncation(truncation: Optional) = truncation(truncation.getOrNull()) /** @@ -1777,6 +1781,7 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ + @Deprecated("deprecated") fun truncation(truncation: JsonField) = apply { this.truncation = truncation } /** @@ -3893,6 +3898,7 @@ private constructor( * - `disabled` (default): If the input size will exceed the context window size for a model, * the request will fail with a 400 error. */ + @Deprecated("deprecated") class Truncation @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt index 5a8891f47..bbc637a89 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParams.kt @@ -187,7 +187,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun truncation(): Optional = body.truncation() + @Deprecated("deprecated") fun truncation(): Optional = body.truncation() /** * Returns the raw JSON value of [conversation]. @@ -273,7 +273,7 @@ private constructor( * * Unlike [truncation], this method doesn't throw if the JSON field has an unexpected type. */ - fun _truncation(): JsonField = body._truncation() + @Deprecated("deprecated") fun _truncation(): JsonField = body._truncation() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -714,6 +714,7 @@ private constructor( * `disabled` (default): If the input size will exceed the context window size for a model, * the request will fail with a 400 error. */ + @Deprecated("deprecated") fun truncation(truncation: Truncation) = apply { body.truncation(truncation) } /** @@ -723,6 +724,7 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ + @Deprecated("deprecated") fun truncation(truncation: JsonField) = apply { body.truncation(truncation) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { @@ -1043,6 +1045,7 @@ private constructor( * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ + @Deprecated("deprecated") fun truncation(): Optional = truncation.getOptional("truncation") /** @@ -1145,6 +1148,7 @@ private constructor( * * Unlike [truncation], this method doesn't throw if the JSON field has an unexpected type. */ + @Deprecated("deprecated") @JsonProperty("truncation") @ExcludeMissing fun _truncation(): JsonField = truncation @@ -1616,6 +1620,7 @@ private constructor( * conversation. - `disabled` (default): If the input size will exceed the context * window size for a model, the request will fail with a 400 error. */ + @Deprecated("deprecated") fun truncation(truncation: Truncation) = truncation(JsonField.of(truncation)) /** @@ -1625,6 +1630,7 @@ private constructor( * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ + @Deprecated("deprecated") fun truncation(truncation: JsonField) = apply { this.truncation = truncation } @@ -3241,6 +3247,7 @@ private constructor( * (default): If the input size will exceed the context window size for a model, the request * will fail with a 400 error. */ + @Deprecated("deprecated") class Truncation @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsync.kt index ff416b2d2..2a63a343c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsync.kt @@ -11,6 +11,7 @@ import com.openai.models.admin.organization.spendalerts.SpendAlertCreateParams import com.openai.models.admin.organization.spendalerts.SpendAlertDeleteParams import com.openai.models.admin.organization.spendalerts.SpendAlertListPageAsync import com.openai.models.admin.organization.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.spendalerts.SpendAlertUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -39,6 +40,41 @@ interface SpendAlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** Retrieves an organization spend alert. */ + fun retrieve(alertId: String): CompletableFuture = + retrieve(alertId, SpendAlertRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + ): CompletableFuture = retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: SpendAlertRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(alertId, SpendAlertRetrieveParams.none(), requestOptions) + /** Updates an organization spend alert. */ fun update( alertId: String, @@ -147,6 +183,47 @@ interface SpendAlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `get /organization/spend_alerts/{alert_id}`, but is + * otherwise the same as [SpendAlertServiceAsync.retrieve]. + */ + fun retrieve(alertId: String): CompletableFuture> = + retrieve(alertId, SpendAlertRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + ): CompletableFuture> = + retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(alertId, SpendAlertRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /organization/spend_alerts/{alert_id}`, but is * otherwise the same as [SpendAlertServiceAsync.update]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncImpl.kt index 3e811c34b..9da956a46 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.admin.organization.spendalerts.SpendAlertDeleteParams import com.openai.models.admin.organization.spendalerts.SpendAlertListPageAsync import com.openai.models.admin.organization.spendalerts.SpendAlertListPageResponse import com.openai.models.admin.organization.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.spendalerts.SpendAlertUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -48,6 +49,13 @@ class SpendAlertServiceAsyncImpl internal constructor(private val clientOptions: // post /organization/spend_alerts withRawResponse().create(params, requestOptions).thenApply { it.parse() } + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /organization/spend_alerts/{alert_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + override fun update( params: SpendAlertUpdateParams, requestOptions: RequestOptions, @@ -117,6 +125,43 @@ class SpendAlertServiceAsyncImpl internal constructor(private val clientOptions: } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertId", params.alertId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "spend_alerts", params._pathParam(0)) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsync.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsync.kt index b9cdefa63..95b762cdf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsync.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsync.kt @@ -11,6 +11,7 @@ import com.openai.models.admin.organization.projects.spendalerts.SpendAlertCreat import com.openai.models.admin.organization.projects.spendalerts.SpendAlertDeleteParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListPageAsync import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.projects.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -53,6 +54,30 @@ interface SpendAlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** Retrieves a project spend alert. */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + ): CompletableFuture = retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: SpendAlertRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** Updates a project spend alert. */ fun update( alertId: String, @@ -181,6 +206,37 @@ interface SpendAlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `get + * /organization/projects/{project_id}/spend_alerts/{alert_id}`, but is otherwise the same + * as [SpendAlertServiceAsync.retrieve]. + */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + ): CompletableFuture> = + retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post * /organization/projects/{project_id}/spend_alerts/{alert_id}`, but is otherwise the same diff --git a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncImpl.kt index 708b4efcb..d94d64ece 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.admin.organization.projects.spendalerts.SpendAlertDelet import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListPageAsync import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListPageResponse import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.projects.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertUpdateParams import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -48,6 +49,13 @@ class SpendAlertServiceAsyncImpl internal constructor(private val clientOptions: // post /organization/projects/{project_id}/spend_alerts withRawResponse().create(params, requestOptions).thenApply { it.parse() } + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /organization/projects/{project_id}/spend_alerts/{alert_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + override fun update( params: SpendAlertUpdateParams, requestOptions: RequestOptions, @@ -125,6 +133,49 @@ class SpendAlertServiceAsyncImpl internal constructor(private val clientOptions: } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertId", params.alertId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "organization", + "projects", + params._pathParam(0), + "spend_alerts", + params._pathParam(1), + ) + .build() + .prepareAsync( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertService.kt index 21e437a5e..e5e52ffd4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertService.kt @@ -12,6 +12,7 @@ import com.openai.models.admin.organization.spendalerts.SpendAlertCreateParams import com.openai.models.admin.organization.spendalerts.SpendAlertDeleteParams import com.openai.models.admin.organization.spendalerts.SpendAlertListPage import com.openai.models.admin.organization.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.spendalerts.SpendAlertUpdateParams import java.util.function.Consumer @@ -39,6 +40,38 @@ interface SpendAlertService { requestOptions: RequestOptions = RequestOptions.none(), ): OrganizationSpendAlert + /** Retrieves an organization spend alert. */ + fun retrieve(alertId: String): OrganizationSpendAlert = + retrieve(alertId, SpendAlertRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationSpendAlert = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + ): OrganizationSpendAlert = retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): OrganizationSpendAlert + + /** @see retrieve */ + fun retrieve(params: SpendAlertRetrieveParams): OrganizationSpendAlert = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(alertId: String, requestOptions: RequestOptions): OrganizationSpendAlert = + retrieve(alertId, SpendAlertRetrieveParams.none(), requestOptions) + /** Updates an organization spend alert. */ fun update(alertId: String, params: SpendAlertUpdateParams): OrganizationSpendAlert = update(alertId, params, RequestOptions.none()) @@ -136,6 +169,51 @@ interface SpendAlertService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `get /organization/spend_alerts/{alert_id}`, but is + * otherwise the same as [SpendAlertService.retrieve]. + */ + @MustBeClosed + fun retrieve(alertId: String): HttpResponseFor = + retrieve(alertId, SpendAlertRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams = SpendAlertRetrieveParams.none(), + ): HttpResponseFor = + retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: SpendAlertRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + alertId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(alertId, SpendAlertRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /organization/spend_alerts/{alert_id}`, but is * otherwise the same as [SpendAlertService.update]. diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceImpl.kt index 2f295be63..3ad432189 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.admin.organization.spendalerts.SpendAlertDeleteParams import com.openai.models.admin.organization.spendalerts.SpendAlertListPage import com.openai.models.admin.organization.spendalerts.SpendAlertListPageResponse import com.openai.models.admin.organization.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.spendalerts.SpendAlertUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -47,6 +48,13 @@ class SpendAlertServiceImpl internal constructor(private val clientOptions: Clie // post /organization/spend_alerts withRawResponse().create(params, requestOptions).parse() + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): OrganizationSpendAlert = + // get /organization/spend_alerts/{alert_id} + withRawResponse().retrieve(params, requestOptions).parse() + override fun update( params: SpendAlertUpdateParams, requestOptions: RequestOptions, @@ -113,6 +121,40 @@ class SpendAlertServiceImpl internal constructor(private val clientOptions: Clie } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertId", params.alertId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("organization", "spend_alerts", params._pathParam(0)) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertService.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertService.kt index b7badc943..0e6595beb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertService.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertService.kt @@ -12,6 +12,7 @@ import com.openai.models.admin.organization.projects.spendalerts.SpendAlertCreat import com.openai.models.admin.organization.projects.spendalerts.SpendAlertDeleteParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListPage import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.projects.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertUpdateParams import java.util.function.Consumer @@ -50,6 +51,27 @@ interface SpendAlertService { requestOptions: RequestOptions = RequestOptions.none(), ): ProjectSpendAlert + /** Retrieves a project spend alert. */ + fun retrieve(alertId: String, params: SpendAlertRetrieveParams): ProjectSpendAlert = + retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectSpendAlert = retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: SpendAlertRetrieveParams): ProjectSpendAlert = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProjectSpendAlert + /** Updates a project spend alert. */ fun update(alertId: String, params: SpendAlertUpdateParams): ProjectSpendAlert = update(alertId, params, RequestOptions.none()) @@ -165,6 +187,38 @@ interface SpendAlertService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `get + * /organization/projects/{project_id}/spend_alerts/{alert_id}`, but is otherwise the same + * as [SpendAlertService.retrieve]. + */ + @MustBeClosed + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + ): HttpResponseFor = retrieve(alertId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + alertId: String, + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: SpendAlertRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post * /organization/projects/{project_id}/spend_alerts/{alert_id}`, but is otherwise the same diff --git a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceImpl.kt b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceImpl.kt index 9497dbd05..ba64a035e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceImpl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceImpl.kt @@ -24,6 +24,7 @@ import com.openai.models.admin.organization.projects.spendalerts.SpendAlertDelet import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListPage import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListPageResponse import com.openai.models.admin.organization.projects.spendalerts.SpendAlertListParams +import com.openai.models.admin.organization.projects.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertUpdateParams import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -47,6 +48,13 @@ class SpendAlertServiceImpl internal constructor(private val clientOptions: Clie // post /organization/projects/{project_id}/spend_alerts withRawResponse().create(params, requestOptions).parse() + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): ProjectSpendAlert = + // get /organization/projects/{project_id}/spend_alerts/{alert_id} + withRawResponse().retrieve(params, requestOptions).parse() + override fun update( params: SpendAlertUpdateParams, requestOptions: RequestOptions, @@ -121,6 +129,46 @@ class SpendAlertServiceImpl internal constructor(private val clientOptions: Clie } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: SpendAlertRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertId", params.alertId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "organization", + "projects", + params._pathParam(0), + "spend_alerts", + params._pathParam(1), + ) + .build() + .prepare( + clientOptions, + params, + SecurityOptions.builder().adminApiKeyAuth(true).build(), + ) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ReasoningTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ReasoningTest.kt index 25d8ff460..48ece51b3 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ReasoningTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ReasoningTest.kt @@ -13,11 +13,13 @@ internal class ReasoningTest { fun create() { val reasoning = Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) .build() + assertThat(reasoning.context()).contains(Reasoning.Context.AUTO) assertThat(reasoning.effort()).contains(ReasoningEffort.NONE) assertThat(reasoning.generateSummary()).contains(Reasoning.GenerateSummary.AUTO) assertThat(reasoning.summary()).contains(Reasoning.Summary.AUTO) @@ -28,6 +30,7 @@ internal class ReasoningTest { val jsonMapper = jsonMapper() val reasoning = Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParamsTest.kt index c8b0039de..ef7bf486c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateParamsTest.kt @@ -9,11 +9,25 @@ internal class AdminApiKeyCreateParamsTest { @Test fun create() { - AdminApiKeyCreateParams.builder().name("New Admin Key").build() + AdminApiKeyCreateParams.builder().name("New Admin Key").expiresInSeconds(2592000L).build() } @Test fun body() { + val params = + AdminApiKeyCreateParams.builder() + .name("New Admin Key") + .expiresInSeconds(2592000L) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("New Admin Key") + assertThat(body.expiresInSeconds()).contains(2592000L) + } + + @Test + fun bodyWithoutOptionalFields() { val params = AdminApiKeyCreateParams.builder().name("New Admin Key").build() val body = params._body() diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponseTest.kt index 76be38c97..ef8235a27 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyCreateResponseTest.kt @@ -15,6 +15,7 @@ internal class AdminApiKeyCreateResponseTest { AdminApiKeyCreateResponse.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") @@ -33,6 +34,7 @@ internal class AdminApiKeyCreateResponseTest { assertThat(adminApiKeyCreateResponse.id()).isEqualTo("key_abc") assertThat(adminApiKeyCreateResponse.createdAt()).isEqualTo(1711471533L) + assertThat(adminApiKeyCreateResponse.expiresAt()).contains(1714063533L) assertThat(adminApiKeyCreateResponse.owner()) .isEqualTo( AdminApiKey.Owner.builder() @@ -57,6 +59,7 @@ internal class AdminApiKeyCreateResponseTest { AdminApiKeyCreateResponse.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponseTest.kt index a5d607f68..7d81915d6 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponseTest.kt @@ -17,6 +17,7 @@ internal class AdminApiKeyListPageResponseTest { AdminApiKey.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") @@ -42,6 +43,7 @@ internal class AdminApiKeyListPageResponseTest { AdminApiKey.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") @@ -71,6 +73,7 @@ internal class AdminApiKeyListPageResponseTest { AdminApiKey.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyTest.kt index dd161c775..cb48000ae 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyTest.kt @@ -15,6 +15,7 @@ internal class AdminApiKeyTest { AdminApiKey.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") @@ -32,6 +33,7 @@ internal class AdminApiKeyTest { assertThat(adminApiKey.id()).isEqualTo("key_abc") assertThat(adminApiKey.createdAt()).isEqualTo(1711471533L) + assertThat(adminApiKey.expiresAt()).contains(1714063533L) assertThat(adminApiKey.owner()) .isEqualTo( AdminApiKey.Owner.builder() @@ -55,6 +57,7 @@ internal class AdminApiKeyTest { AdminApiKey.builder() .id("key_abc") .createdAt(1711471533L) + .expiresAt(1714063533L) .owner( AdminApiKey.Owner.builder() .id("sa_456") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponseTest.kt index 107dd269c..b0fc84453 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponseTest.kt @@ -317,6 +317,20 @@ internal class AuditLogListPageResponseTest { .resourceType("resource_type") .build() ) + .roleBoundToResource( + AuditLogListResponse.RoleBoundToResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleBoundToResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleCreated( AuditLogListResponse.RoleCreated.builder() .id("id") @@ -327,6 +341,22 @@ internal class AuditLogListPageResponseTest { .build() ) .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build()) + .roleUnboundFromResource( + AuditLogListResponse.RoleUnboundFromResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source( + AuditLogListResponse.RoleUnboundFromResource.Source.ROLE_TOGGLE + ) + .workspaceId("workspace_id") + .build() + ) .roleUpdated( AuditLogListResponse.RoleUpdated.builder() .id("id") @@ -725,6 +755,20 @@ internal class AuditLogListPageResponseTest { .resourceType("resource_type") .build() ) + .roleBoundToResource( + AuditLogListResponse.RoleBoundToResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleBoundToResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleCreated( AuditLogListResponse.RoleCreated.builder() .id("id") @@ -735,6 +779,20 @@ internal class AuditLogListPageResponseTest { .build() ) .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build()) + .roleUnboundFromResource( + AuditLogListResponse.RoleUnboundFromResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleUnboundFromResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleUpdated( AuditLogListResponse.RoleUpdated.builder() .id("id") @@ -1151,6 +1209,20 @@ internal class AuditLogListPageResponseTest { .resourceType("resource_type") .build() ) + .roleBoundToResource( + AuditLogListResponse.RoleBoundToResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleBoundToResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleCreated( AuditLogListResponse.RoleCreated.builder() .id("id") @@ -1161,6 +1233,22 @@ internal class AuditLogListPageResponseTest { .build() ) .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build()) + .roleUnboundFromResource( + AuditLogListResponse.RoleUnboundFromResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source( + AuditLogListResponse.RoleUnboundFromResource.Source.ROLE_TOGGLE + ) + .workspaceId("workspace_id") + .build() + ) .roleUpdated( AuditLogListResponse.RoleUpdated.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParamsTest.kt index 9520829e1..9f15fc803 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListParamsTest.kt @@ -22,6 +22,7 @@ internal class AuditLogListParamsTest { .limit(0L) .addProjectId("string") .addResourceId("string") + .tenantOnly(true) .build() } @@ -40,6 +41,7 @@ internal class AuditLogListParamsTest { .limit(0L) .addProjectId("string") .addResourceId("string") + .tenantOnly(true) .build() val queryParams = params._queryParams() @@ -59,6 +61,7 @@ internal class AuditLogListParamsTest { .put("limit", "0") .put("project_ids[]", "string") .put("resource_ids[]", "string") + .put("tenant_only", "true") .build() ) } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponseTest.kt index 56b3a2eeb..233eecc5c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListResponseTest.kt @@ -289,6 +289,20 @@ internal class AuditLogListResponseTest { .resourceType("resource_type") .build() ) + .roleBoundToResource( + AuditLogListResponse.RoleBoundToResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleBoundToResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleCreated( AuditLogListResponse.RoleCreated.builder() .id("id") @@ -299,6 +313,20 @@ internal class AuditLogListResponseTest { .build() ) .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build()) + .roleUnboundFromResource( + AuditLogListResponse.RoleUnboundFromResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleUnboundFromResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleUpdated( AuditLogListResponse.RoleUpdated.builder() .id("id") @@ -706,6 +734,21 @@ internal class AuditLogListResponseTest { .resourceType("resource_type") .build() ) + assertThat(auditLogListResponse.roleBoundToResource()) + .contains( + AuditLogListResponse.RoleBoundToResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleBoundToResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) assertThat(auditLogListResponse.roleCreated()) .contains( AuditLogListResponse.RoleCreated.builder() @@ -718,6 +761,21 @@ internal class AuditLogListResponseTest { ) assertThat(auditLogListResponse.roleDeleted()) .contains(AuditLogListResponse.RoleDeleted.builder().id("id").build()) + assertThat(auditLogListResponse.roleUnboundFromResource()) + .contains( + AuditLogListResponse.RoleUnboundFromResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleUnboundFromResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) assertThat(auditLogListResponse.roleUpdated()) .contains( AuditLogListResponse.RoleUpdated.builder() @@ -1111,6 +1169,20 @@ internal class AuditLogListResponseTest { .resourceType("resource_type") .build() ) + .roleBoundToResource( + AuditLogListResponse.RoleBoundToResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleBoundToResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleCreated( AuditLogListResponse.RoleCreated.builder() .id("id") @@ -1121,6 +1193,20 @@ internal class AuditLogListResponseTest { .build() ) .roleDeleted(AuditLogListResponse.RoleDeleted.builder().id("id").build()) + .roleUnboundFromResource( + AuditLogListResponse.RoleUnboundFromResource.builder() + .id("id") + .connectorId("connector_id") + .connectorName("connector_name") + .enabled(true) + .addPermission("string") + .resourceId("resource_id") + .resourceType("resource_type") + .roleId("role_id") + .source(AuditLogListResponse.RoleUnboundFromResource.Source.ROLE_TOGGLE) + .workspaceId("workspace_id") + .build() + ) .roleUpdated( AuditLogListResponse.RoleUpdated.builder() .id("id") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/projects/spendalerts/SpendAlertRetrieveParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/projects/spendalerts/SpendAlertRetrieveParamsTest.kt new file mode 100644 index 000000000..ca373b47e --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/projects/spendalerts/SpendAlertRetrieveParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.admin.organization.projects.spendalerts + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SpendAlertRetrieveParamsTest { + + @Test + fun create() { + SpendAlertRetrieveParams.builder().projectId("project_id").alertId("alert_id").build() + } + + @Test + fun pathParams() { + val params = + SpendAlertRetrieveParams.builder().projectId("project_id").alertId("alert_id").build() + + assertThat(params._pathParam(0)).isEqualTo("project_id") + assertThat(params._pathParam(1)).isEqualTo("alert_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/spendalerts/SpendAlertRetrieveParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/spendalerts/SpendAlertRetrieveParamsTest.kt new file mode 100644 index 000000000..48aac2899 --- /dev/null +++ b/openai-java-core/src/test/kotlin/com/openai/models/admin/organization/spendalerts/SpendAlertRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.admin.organization.spendalerts + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SpendAlertRetrieveParamsTest { + + @Test + fun create() { + SpendAlertRetrieveParams.builder().alertId("alert_id").build() + } + + @Test + fun pathParams() { + val params = SpendAlertRetrieveParams.builder().alertId("alert_id").build() + + assertThat(params._pathParam(0)).isEqualTo("alert_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt index 5901cdbd2..e4357cdbc 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCompletedEventTest.kt @@ -173,6 +173,7 @@ internal class ResponseCompletedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -366,6 +367,7 @@ internal class ResponseCompletedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -563,6 +565,7 @@ internal class ResponseCompletedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt index 98fca12ca..4e7a040ed 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreateParamsTest.kt @@ -54,6 +54,7 @@ internal class ResponseCreateParamsTest { .promptCacheRetention(ResponseCreateParams.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -134,6 +135,7 @@ internal class ResponseCreateParamsTest { .promptCacheRetention(ResponseCreateParams.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -218,6 +220,7 @@ internal class ResponseCreateParamsTest { assertThat(body.reasoning()) .contains( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt index f0336dff6..9a8bf133a 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseCreatedEventTest.kt @@ -173,6 +173,7 @@ internal class ResponseCreatedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -366,6 +367,7 @@ internal class ResponseCreatedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -563,6 +565,7 @@ internal class ResponseCreatedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt index d671e76b2..ce40c5eb5 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseFailedEventTest.kt @@ -173,6 +173,7 @@ internal class ResponseFailedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -366,6 +367,7 @@ internal class ResponseFailedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -563,6 +565,7 @@ internal class ResponseFailedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt index bcd9d8b1e..3cf5f74f6 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseInProgressEventTest.kt @@ -173,6 +173,7 @@ internal class ResponseInProgressEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -366,6 +367,7 @@ internal class ResponseInProgressEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -563,6 +565,7 @@ internal class ResponseInProgressEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt index af04377d1..68575d138 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseIncompleteEventTest.kt @@ -173,6 +173,7 @@ internal class ResponseIncompleteEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -366,6 +367,7 @@ internal class ResponseIncompleteEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -563,6 +565,7 @@ internal class ResponseIncompleteEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt index 5d0a53da5..6f0c8b7ee 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseQueuedEventTest.kt @@ -173,6 +173,7 @@ internal class ResponseQueuedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -366,6 +367,7 @@ internal class ResponseQueuedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -563,6 +565,7 @@ internal class ResponseQueuedEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt index 71e519eb1..732c8c2d2 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseStreamEventTest.kt @@ -943,6 +943,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -1209,6 +1210,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -1699,6 +1701,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -1965,6 +1968,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -2711,6 +2715,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -2977,6 +2982,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3185,6 +3191,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3451,6 +3458,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3659,6 +3667,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3925,6 +3934,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -6823,6 +6833,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -7089,6 +7100,7 @@ internal class ResponseStreamEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt index 725b704b9..6f6d608e8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponseTest.kt @@ -168,6 +168,7 @@ internal class ResponseTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -355,6 +356,7 @@ internal class ResponseTest { assertThat(response.reasoning()) .contains( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -543,6 +545,7 @@ internal class ResponseTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesClientEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesClientEventTest.kt index c60cfd4ab..2169585ff 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesClientEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesClientEventTest.kt @@ -57,6 +57,7 @@ internal class ResponsesClientEventTest { .promptCacheRetention(ResponsesClientEvent.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -142,6 +143,7 @@ internal class ResponsesClientEventTest { assertThat(responsesClientEvent.reasoning()) .contains( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -228,6 +230,7 @@ internal class ResponsesClientEventTest { .promptCacheRetention(ResponsesClientEvent.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt index c0533bda9..9a9afe1e8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/ResponsesServerEventTest.kt @@ -958,6 +958,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -1224,6 +1225,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -1717,6 +1719,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -1983,6 +1986,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -2737,6 +2741,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3003,6 +3008,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3211,6 +3217,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3477,6 +3484,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3685,6 +3693,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -3951,6 +3960,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -6892,6 +6902,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -7158,6 +7169,7 @@ internal class ResponsesServerEventTest { .promptCacheRetention(Response.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParamsTest.kt index 5c58c4d12..eb711c949 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/responses/inputtokens/InputTokenCountParamsTest.kt @@ -27,6 +27,7 @@ internal class InputTokenCountParamsTest { .previousResponseId("resp_123") .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -69,6 +70,7 @@ internal class InputTokenCountParamsTest { .previousResponseId("resp_123") .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -109,6 +111,7 @@ internal class InputTokenCountParamsTest { assertThat(body.reasoning()) .contains( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt index 9e3ccf882..234f5d958 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/ResponseServiceAsyncTest.kt @@ -74,6 +74,7 @@ internal class ResponseServiceAsyncTest { .promptCacheRetention(ResponseCreateParams.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -170,6 +171,7 @@ internal class ResponseServiceAsyncTest { .promptCacheRetention(ResponseCreateParams.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/AdminApiKeyServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/AdminApiKeyServiceAsyncTest.kt index 9bb0ef6d6..8b555a77c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/AdminApiKeyServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/AdminApiKeyServiceAsyncTest.kt @@ -23,7 +23,10 @@ internal class AdminApiKeyServiceAsyncTest { val adminApiKeyFuture = adminApiKeyServiceAsync.create( - AdminApiKeyCreateParams.builder().name("New Admin Key").build() + AdminApiKeyCreateParams.builder() + .name("New Admin Key") + .expiresInSeconds(2592000L) + .build() ) val adminApiKey = adminApiKeyFuture.get() diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncTest.kt index a208e2064..b6bbf10a3 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/SpendAlertServiceAsyncTest.kt @@ -41,6 +41,22 @@ internal class SpendAlertServiceAsyncTest { organizationSpendAlert.validate() } + @Test + fun retrieve() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val spendAlertServiceAsync = client.admin().organization().spendAlerts() + + val organizationSpendAlertFuture = spendAlertServiceAsync.retrieve("alert_id") + + val organizationSpendAlert = organizationSpendAlertFuture.get() + organizationSpendAlert.validate() + } + @Test fun update() { val client = diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncTest.kt index 1974faa0c..f02f16936 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/admin/organization/projects/SpendAlertServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClientAsync import com.openai.models.admin.organization.projects.spendalerts.SpendAlertCreateParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertDeleteParams +import com.openai.models.admin.organization.projects.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -43,6 +44,28 @@ internal class SpendAlertServiceAsyncTest { projectSpendAlert.validate() } + @Test + fun retrieve() { + val client = + OpenAIOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val spendAlertServiceAsync = client.admin().organization().projects().spendAlerts() + + val projectSpendAlertFuture = + spendAlertServiceAsync.retrieve( + SpendAlertRetrieveParams.builder() + .projectId("project_id") + .alertId("alert_id") + .build() + ) + + val projectSpendAlert = projectSpendAlertFuture.get() + projectSpendAlert.validate() + } + @Test fun update() { val client = diff --git a/openai-java-core/src/test/kotlin/com/openai/services/async/responses/InputTokenServiceAsyncTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/async/responses/InputTokenServiceAsyncTest.kt index ef0c8f6c9..933794417 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/async/responses/InputTokenServiceAsyncTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/async/responses/InputTokenServiceAsyncTest.kt @@ -39,6 +39,7 @@ internal class InputTokenServiceAsyncTest { .previousResponseId("resp_123") .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt index 123e08db6..2685a4b70 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/ResponseServiceTest.kt @@ -74,6 +74,7 @@ internal class ResponseServiceTest { .promptCacheRetention(ResponseCreateParams.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) @@ -169,6 +170,7 @@ internal class ResponseServiceTest { .promptCacheRetention(ResponseCreateParams.PromptCacheRetention.IN_MEMORY) .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/AdminApiKeyServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/AdminApiKeyServiceTest.kt index 1154fd22b..f719683bc 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/AdminApiKeyServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/AdminApiKeyServiceTest.kt @@ -23,7 +23,10 @@ internal class AdminApiKeyServiceTest { val adminApiKey = adminApiKeyService.create( - AdminApiKeyCreateParams.builder().name("New Admin Key").build() + AdminApiKeyCreateParams.builder() + .name("New Admin Key") + .expiresInSeconds(2592000L) + .build() ) adminApiKey.validate() diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceTest.kt index bd1d7f3c9..87bfc7557 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/SpendAlertServiceTest.kt @@ -40,6 +40,21 @@ internal class SpendAlertServiceTest { organizationSpendAlert.validate() } + @Test + fun retrieve() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val spendAlertService = client.admin().organization().spendAlerts() + + val organizationSpendAlert = spendAlertService.retrieve("alert_id") + + organizationSpendAlert.validate() + } + @Test fun update() { val client = diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceTest.kt index d2ab41b6c..8047947cf 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/admin/organization/projects/SpendAlertServiceTest.kt @@ -6,6 +6,7 @@ import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClient import com.openai.models.admin.organization.projects.spendalerts.SpendAlertCreateParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertDeleteParams +import com.openai.models.admin.organization.projects.spendalerts.SpendAlertRetrieveParams import com.openai.models.admin.organization.projects.spendalerts.SpendAlertUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -42,6 +43,27 @@ internal class SpendAlertServiceTest { projectSpendAlert.validate() } + @Test + fun retrieve() { + val client = + OpenAIOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .adminApiKey("My Admin API Key") + .build() + val spendAlertService = client.admin().organization().projects().spendAlerts() + + val projectSpendAlert = + spendAlertService.retrieve( + SpendAlertRetrieveParams.builder() + .projectId("project_id") + .alertId("alert_id") + .build() + ) + + projectSpendAlert.validate() + } + @Test fun update() { val client = diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/responses/InputTokenServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/responses/InputTokenServiceTest.kt index b94b1874b..469e9cbab 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/responses/InputTokenServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/responses/InputTokenServiceTest.kt @@ -39,6 +39,7 @@ internal class InputTokenServiceTest { .previousResponseId("resp_123") .reasoning( Reasoning.builder() + .context(Reasoning.Context.AUTO) .effort(ReasoningEffort.NONE) .generateSummary(Reasoning.GenerateSummary.AUTO) .summary(Reasoning.Summary.AUTO)