diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 7dc692e1f..25e9535f2 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.34.0" + ".": "4.35.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index ab1af60f9..74bb7cc4f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 232 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-21ecab7aeb61612b9da5e52ea4c0cb75a33d443d975022934b9305e97d1a7d62.yml -openapi_spec_hash: cfc868a0bb3567183510c9b5629c510f -config_hash: dd484e2cc01206d26516338d0f4596b0 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-08cb8ed18dfe4a9fa518e278576d3cfe5710cb5c22789cf80826c900569bcf56.yml +openapi_spec_hash: 20f820c94f54741b75d719f6a7371c12 +config_hash: f291a449469edfe61a28424e548899b2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 41adf3b0c..34f266d61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,47 @@ # Changelog +## 4.35.0 (2026-05-07) + +Full Changelog: [v4.34.0...v4.35.0](https://github.com/openai/openai-java/compare/v4.34.0...v4.35.0) + +### Features + +* **api:** add quantity field to organization usage responses, update topLogprobs docs ([d4686cc](https://github.com/openai/openai-java/commit/d4686cc7eb9bcd551282d421811341518ddc8584)) +* **api:** launch realtime translate + update image 2 ([28ad918](https://github.com/openai/openai-java/commit/28ad9189d7293388d043ed83496333132afc517f)) +* **api:** manual updates ([7905ef6](https://github.com/openai/openai-java/commit/7905ef6cc30852f0d80bd10c937d949028ff1303)) +* **api:** manual updates ([8328a1e](https://github.com/openai/openai-java/commit/8328a1eb51291dd0a317989e31e0989572bbfa0b)) +* **client:** improve logging ([6393b34](https://github.com/openai/openai-java/commit/6393b3431e87d15ad3ee23cc274161f8e00a87ec)) +* **client:** more robust error parsing ([5a1bfdc](https://github.com/openai/openai-java/commit/5a1bfdcb283dc6efc1ab5058ef96740087112288)) +* **client:** support proxy authentication ([97c8087](https://github.com/openai/openai-java/commit/97c808706c3684892d309245a205fcfcf90738cd)) + + +### Bug Fixes + +* **api:** fix imagegen `size` enum regression ([aacb886](https://github.com/openai/openai-java/commit/aacb886fd99a7571dabe5bc8f1086bef650c11fc)) +* **client:** match `JsonSchemaValidator` heading levels to API ([#733](https://github.com/openai/openai-java/issues/733)) ([fc57ef7](https://github.com/openai/openai-java/commit/fc57ef7963e6ebdfde0c716adc4f29d315dc9021)) +* **logging:** redact Azure api-key header in logging ([#717](https://github.com/openai/openai-java/issues/717)) ([157207f](https://github.com/openai/openai-java/commit/157207fefe59174141a5aec6a983c546def242b4)) + + +### Performance Improvements + +* **client:** create one json mapper ([6bdc12e](https://github.com/openai/openai-java/commit/6bdc12ed832827d3e9bdb9825898bfa5aee94d26)) + + +### Chores + +* fix build error ([82a8527](https://github.com/openai/openai-java/commit/82a85274f613aad7ae277765b12bc3469832e1b1)) +* redact api-key headers in debug logs ([73d01b0](https://github.com/openai/openai-java/commit/73d01b0a5a9af1e4722381701654ff5880ff8986)) +* remove duplicated dokka setup ([06e43e2](https://github.com/openai/openai-java/commit/06e43e2ca1a630dd8b4d38b151724d6b3fb5e014)) +* **tests:** update test fixtures to use valid example URLs ([021f44a](https://github.com/openai/openai-java/commit/021f44a12a39f7e1b8e405e4f309f1a4d0223ed6)) + + +### Documentation + +* **api:** document web_search_call.results in response includables ([18fe08a](https://github.com/openai/openai-java/commit/18fe08af6a53d6ef9b35e03190e137b02231608e)) +* clarify forwards compat behavior ([d44f466](https://github.com/openai/openai-java/commit/d44f4664a550f4d34b2d1b14c7f376d1047514e0)) +* clarify structured output map limitations ([#726](https://github.com/openai/openai-java/issues/726)) ([e1e1161](https://github.com/openai/openai-java/commit/e1e1161d69d30bd6639ada5ead3a30f14c68cf8d)) +* remove bad semicolon ([#725](https://github.com/openai/openai-java/issues/725)) ([b5dbd07](https://github.com/openai/openai-java/commit/b5dbd07e1147f5554509481798978717e22b03af)) + ## 4.34.0 (2026-05-01) Full Changelog: [v4.33.0...v4.34.0](https://github.com/openai/openai-java/compare/v4.33.0...v4.34.0) diff --git a/README.md b/README.md index 6e80eae21..5cdfe2939 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.34.0) -[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.34.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.34.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/4.35.0) +[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/4.35.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/4.35.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.34.0). +The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/4.35.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.34.0") +implementation("com.openai:openai-java:4.35.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.openai:openai-java:4.34.0") com.openai openai-java - 4.34.0 + 4.35.0 ``` @@ -349,7 +349,7 @@ client.async().chat().completions().createStreaming(params) .subscribe(chunk -> { System.out.println(chunk); }) - .onCompleteFuture(); + .onCompleteFuture() .whenComplete((unused, error) -> { if (error != null) { System.out.println("Something went wrong!"); @@ -711,6 +711,8 @@ properties can be derived. This may occur if, for example: - All fields and getter methods are non-`public`, but none are annotated with `@JsonProperty`. - A field or getter method is declared with a `Map` type. A `Map` is treated like a separate class with no named properties, so it will result in an empty `"properties"` field in the JSON schema. + If you need arbitrary key/value data, model it as a list of entry objects with named fields so the + generated schema still has concrete property names. ### Annotating classes and JSON schemas @@ -1384,8 +1386,6 @@ while (true) { ## Logging -The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). - Enable logging by setting the `OPENAI_LOG` environment variable to `info`: ```sh @@ -1398,6 +1398,19 @@ Or to `debug` for more verbose logging: export OPENAI_LOG=debug ``` +Or configure the client manually using the `logLevel` method: + +```java +import com.openai.client.OpenAIClient; +import com.openai.client.okhttp.OpenAIOkHttpClient; +import com.openai.core.LogLevel; + +OpenAIClient client = OpenAIOkHttpClient.builder() + .fromEnv() + .logLevel(LogLevel.INFO) + .build(); +``` + ## ProGuard and R8 Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `openai-java-core` is published with a [configuration file](openai-java-core/src/main/resources/META-INF/proguard/openai-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). @@ -1421,7 +1434,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.34.0") +implementation("com.openai:openai-java-spring-boot-starter:4.35.0") ``` #### Maven @@ -1430,7 +1443,7 @@ implementation("com.openai:openai-java-spring-boot-starter:4.34.0") com.openai openai-java-spring-boot-starter - 4.34.0 + 4.35.0 ``` @@ -1597,6 +1610,21 @@ OpenAIClient client = OpenAIOkHttpClient.builder() .build(); ``` +If the proxy responds with `407 Proxy Authentication Required`, supply credentials by also configuring `proxyAuthenticator`: + +```java +import com.openai.client.OpenAIClient; +import com.openai.client.okhttp.OpenAIOkHttpClient; +import com.openai.core.http.ProxyAuthenticator; + +OpenAIClient client = OpenAIOkHttpClient.builder() + .fromEnv() + .proxy(...) + // Or a custom implementation of `ProxyAuthenticator`. + .proxyAuthenticator(ProxyAuthenticator.basic("username", "password")) + .build(); +``` + ### Connection pooling To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods: @@ -1837,7 +1865,9 @@ In rare cases, the API may return a response that doesn't match the expected typ By default, the SDK will not throw an exception in this case. It will throw [`OpenAIInvalidDataException`](openai-java-core/src/main/kotlin/com/openai/errors/OpenAIInvalidDataException.kt) only if you directly access the property. -If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: +Validating the response is _not_ forwards compatible with new types from the API for existing fields. + +If you would still prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java import com.openai.models.chat.completions.ChatCompletion; diff --git a/build.gradle.kts b/build.gradle.kts index b5eeb1848..cf1932e56 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.openai" - version = "4.34.0" // x-release-please-version + version = "4.35.0" // x-release-please-version } subprojects { @@ -21,7 +21,6 @@ subprojects { group = "Verification" description = "Verifies all source files are formatted." } - apply(plugin = "org.jetbrains.dokka") } subprojects { diff --git a/openai-java-client-okhttp/build.gradle.kts b/openai-java-client-okhttp/build.gradle.kts index 753e4fbee..4d1eb6170 100644 --- a/openai-java-client-okhttp/build.gradle.kts +++ b/openai-java-client-okhttp/build.gradle.kts @@ -7,7 +7,6 @@ dependencies { api(project(":openai-java-core")) implementation("com.squareup.okhttp3:okhttp:4.12.0") - implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.27.7") diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt index 51c32b0c2..b4aa82d2f 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OkHttpClient.kt @@ -8,9 +8,11 @@ import com.openai.core.http.HttpMethod import com.openai.core.http.HttpRequest import com.openai.core.http.HttpRequestBody import com.openai.core.http.HttpResponse +import com.openai.core.http.ProxyAuthenticator import com.openai.errors.OpenAIIoException import java.io.IOException import java.io.InputStream +import java.io.OutputStream import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException @@ -20,10 +22,12 @@ import java.util.concurrent.TimeUnit import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull import okhttp3.Call import okhttp3.Callback import okhttp3.ConnectionPool import okhttp3.Dispatcher +import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -31,8 +35,9 @@ import okhttp3.Request import okhttp3.RequestBody import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response -import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink +import okio.buffer +import okio.sink class OkHttpClient internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { @@ -41,7 +46,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie val call = newCall(request, requestOptions) return try { - call.execute().toResponse() + call.execute().toHttpResponse() } catch (e: IOException) { throw OpenAIIoException("Request failed", e) } finally { @@ -59,7 +64,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie call.enqueue( object : Callback { override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) + future.complete(response.toHttpResponse()) } override fun onFailure(call: Call, e: IOException) { @@ -87,18 +92,6 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { val clientBuilder = okHttpClient.newBuilder() - val logLevel = - when (System.getenv("OPENAI_LOG")?.lowercase()) { - "info" -> HttpLoggingInterceptor.Level.BASIC - "debug" -> HttpLoggingInterceptor.Level.BODY - else -> null - } - if (logLevel != null) { - clientBuilder.addNetworkInterceptor( - HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } - ) - } - requestOptions.timeout?.let { clientBuilder .connectTimeout(it.connect()) @@ -111,89 +104,6 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie return client.newCall(request.toRequest(client)) } - private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { - var body: RequestBody? = body?.toRequestBody() - if (body == null && requiresBody(method)) { - body = "".toRequestBody() - } - - val builder = Request.Builder().url(toUrl()).method(method.name, body) - headers.names().forEach { name -> - headers.values(name).forEach { builder.addHeader(name, it) } - } - - if ( - !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 - ) { - builder.addHeader( - "X-Stainless-Read-Timeout", - Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), - ) - } - if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.addHeader( - "X-Stainless-Timeout", - Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), - ) - } - - return builder.build() - } - - /** `OkHttpClient` always requires a request body for some methods. */ - private fun requiresBody(method: HttpMethod): Boolean = - when (method) { - HttpMethod.POST, - HttpMethod.PUT, - HttpMethod.PATCH -> true - else -> false - } - - private fun HttpRequest.toUrl(): String { - val builder = baseUrl.toHttpUrl().newBuilder() - pathSegments.forEach(builder::addPathSegment) - queryParams.keys().forEach { key -> - queryParams.values(key).forEach { builder.addQueryParameter(key, it) } - } - - return builder.toString() - } - - private fun HttpRequestBody.toRequestBody(): RequestBody { - val mediaType = contentType()?.toMediaType() - val length = contentLength() - - return object : RequestBody() { - override fun contentType(): MediaType? = mediaType - - override fun contentLength(): Long = length - - override fun isOneShot(): Boolean = !repeatable() - - override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) - } - } - - private fun Response.toResponse(): HttpResponse { - val headers = headers.toHeaders() - - return object : HttpResponse { - override fun statusCode(): Int = code - - override fun headers(): Headers = headers - - override fun body(): InputStream = body!!.byteStream() - - override fun close() = body!!.close() - } - } - - private fun okhttp3.Headers.toHeaders(): Headers { - val headersBuilder = Headers.builder() - forEach { (name, value) -> headersBuilder.put(name, value) } - return headersBuilder.build() - } - companion object { @JvmStatic fun builder() = Builder() } @@ -202,6 +112,7 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var dispatcherExecutorService: ExecutorService? = null @@ -215,6 +126,10 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + /** * Sets the maximum number of idle connections kept by the underlying [ConnectionPool]. * @@ -264,6 +179,19 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie .callTimeout(timeout.request()) .proxy(proxy) .apply { + proxyAuthenticator?.let { auth -> + proxyAuthenticator { route, response -> + auth + .authenticate( + route?.proxy ?: Proxy.NO_PROXY, + response.request.toHttpRequest(), + response.toHttpResponse(), + ) + .getOrNull() + ?.toRequest(client = null) + } + } + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } val maxIdleConnections = maxIdleConnections @@ -303,3 +231,126 @@ internal constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClie ) } } + +private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient?): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> headers.values(name).forEach { builder.addHeader(name, it) } } + + if (client != null) { + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.addHeader( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.addHeader( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + } + + return builder.build() +} + +/** `OkHttpClient` always requires a request body for some methods. */ +private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + +private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() +} + +private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } +} + +private fun Request.toHttpRequest(): HttpRequest { + val builder = HttpRequest.builder().method(HttpMethod.valueOf(method)).baseUrl(url.toBaseUrl()) + url.pathSegments.forEach(builder::addPathSegment) + url.queryParameterNames.forEach { name -> + url.queryParameterValues(name).filterNotNull().forEach { builder.putQueryParam(name, it) } + } + headers.forEach { (name, value) -> builder.putHeader(name, value) } + body?.let { builder.body(it.toHttpRequestBody()) } + return builder.build() +} + +private fun HttpUrl.toBaseUrl(): String = buildString { + append(scheme).append("://").append(host) + if (port != HttpUrl.defaultPort(scheme)) { + append(":").append(port) + } +} + +private fun RequestBody.toHttpRequestBody(): HttpRequestBody { + val mediaType = contentType()?.toString() + val length = contentLength() + val isOneShot = isOneShot() + val source = this + return object : HttpRequestBody { + override fun contentType(): String? = mediaType + + override fun contentLength(): Long = length + + override fun repeatable(): Boolean = !isOneShot + + override fun writeTo(outputStream: OutputStream) { + val sink = outputStream.sink().buffer() + source.writeTo(sink) + sink.flush() + } + + override fun close() {} + } +} + +private fun Response.toHttpResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } +} + +private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() +} diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt index eca395985..59ae7e571 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt @@ -9,11 +9,13 @@ import com.openai.azure.AzureUrlPathMode import com.openai.client.OpenAIClient import com.openai.client.OpenAIClientImpl import com.openai.core.ClientOptions +import com.openai.core.LogLevel import com.openai.core.Sleeper import com.openai.core.Timeout import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.Headers import com.openai.core.http.HttpClient +import com.openai.core.http.ProxyAuthenticator import com.openai.core.http.QueryParams import com.openai.credential.Credential import java.net.Proxy @@ -52,6 +54,7 @@ class OpenAIOkHttpClient private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null @@ -82,6 +85,20 @@ class OpenAIOkHttpClient private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + /** * The maximum number of idle connections kept by the underlying OkHttp connection pool. * @@ -233,6 +250,9 @@ class OpenAIOkHttpClient private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -274,6 +294,15 @@ class OpenAIOkHttpClient private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) } + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ @@ -419,6 +448,7 @@ class OpenAIOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) .maxIdleConnections(maxIdleConnections) .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) diff --git a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt index e3350fb77..a2756a623 100644 --- a/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt +++ b/openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt @@ -9,11 +9,13 @@ import com.openai.azure.AzureUrlPathMode import com.openai.client.OpenAIClientAsync import com.openai.client.OpenAIClientAsyncImpl import com.openai.core.ClientOptions +import com.openai.core.LogLevel import com.openai.core.Sleeper import com.openai.core.Timeout import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.Headers import com.openai.core.http.HttpClient +import com.openai.core.http.ProxyAuthenticator import com.openai.core.http.QueryParams import com.openai.credential.Credential import java.net.Proxy @@ -52,6 +54,7 @@ class OpenAIOkHttpClientAsync private constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null + private var proxyAuthenticator: ProxyAuthenticator? = null private var maxIdleConnections: Int? = null private var keepAliveDuration: Duration? = null private var sslSocketFactory: SSLSocketFactory? = null @@ -82,6 +85,20 @@ class OpenAIOkHttpClientAsync private constructor() { /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + /** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication + * Required`. + */ + fun proxyAuthenticator(proxyAuthenticator: ProxyAuthenticator?) = apply { + this.proxyAuthenticator = proxyAuthenticator + } + + /** + * Alias for calling [Builder.proxyAuthenticator] with `proxyAuthenticator.orElse(null)`. + */ + fun proxyAuthenticator(proxyAuthenticator: Optional) = + proxyAuthenticator(proxyAuthenticator.getOrNull()) + /** * The maximum number of idle connections kept by the underlying OkHttp connection pool. * @@ -233,6 +250,9 @@ class OpenAIOkHttpClientAsync private constructor() { /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -274,6 +294,15 @@ class OpenAIOkHttpClientAsync private constructor() { */ fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { clientOptions.logLevel(logLevel) } + fun apiKey(apiKey: String?) = apply { clientOptions.apiKey(apiKey) } /** Alias for calling [Builder.apiKey] with `apiKey.orElse(null)`. */ @@ -419,6 +448,7 @@ class OpenAIOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .proxyAuthenticator(proxyAuthenticator) .maxIdleConnections(maxIdleConnections) .keepAliveDuration(keepAliveDuration) .dispatcherExecutorService(dispatcherExecutorService) diff --git a/openai-java-core/src/main/kotlin/com/openai/auth/WorkloadIdentityAuth.kt b/openai-java-core/src/main/kotlin/com/openai/auth/WorkloadIdentityAuth.kt index d823a4e6d..1066c3605 100644 --- a/openai-java-core/src/main/kotlin/com/openai/auth/WorkloadIdentityAuth.kt +++ b/openai-java-core/src/main/kotlin/com/openai/auth/WorkloadIdentityAuth.kt @@ -2,6 +2,9 @@ package com.openai.auth import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue import com.openai.core.handlers.errorHandler import com.openai.core.http.HttpClient import com.openai.core.http.HttpMethod @@ -31,22 +34,31 @@ internal class WorkloadIdentityAuth( ) : AutoCloseable { private val errorHandler = errorHandler( - object : HttpResponse.Handler { - override fun handle(response: HttpResponse): ErrorObject? = - try { - val node = jsonMapper.readTree(response.body()) + object : HttpResponse.Handler> { + override fun handle(response: HttpResponse): JsonField { + val node = + try { + jsonMapper.readTree(response.body()) + } catch (e: Exception) { + return JsonMissing.of() + } + + return try { val errorCode = node.get("error")?.asText() val errorMessage = node.get("error_description")?.asText() ?: errorCode - jsonMapper.treeToValue( - jsonMapper.createObjectNode().apply { - errorCode?.let { put("code", it) } - errorMessage?.let { put("message", it) } - }, - ErrorObject::class.java, + JsonField.of( + jsonMapper.treeToValue( + jsonMapper.createObjectNode().apply { + errorCode?.let { put("code", it) } + errorMessage?.let { put("message", it) } + }, + ErrorObject::class.java, + ) ) } catch (e: Exception) { - null + JsonValue.fromJsonNode(node) } + } } ) private val lock = ReentrantLock() diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt index ebacbca2f..e1c430085 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt @@ -12,6 +12,7 @@ import com.openai.azure.credential.AzureApiKeyCredential import com.openai.core.http.AsyncStreamResponse import com.openai.core.http.Headers import com.openai.core.http.HttpClient +import com.openai.core.http.LoggingHttpClient import com.openai.core.http.PhantomReachableClosingHttpClient import com.openai.core.http.QueryParams import com.openai.core.http.RetryingHttpClient @@ -90,6 +91,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for existing + * fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -117,6 +121,14 @@ private constructor( * Defaults to 2. */ @get:JvmName("maxRetries") val maxRetries: Int, + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + @get:JvmName("logLevel") val logLevel: LogLevel, private val apiKey: String?, private val adminApiKey: String?, @get:JvmName("credential") val credential: Credential, @@ -190,6 +202,7 @@ private constructor( private var responseValidation: Boolean = false private var timeout: Timeout = Timeout.default() private var maxRetries: Int = 2 + private var logLevel: LogLevel = LogLevel.fromEnv() private var apiKey: String? = null private var credential: Credential? = null private var azureServiceVersion: AzureOpenAIServiceVersion? = null @@ -214,6 +227,7 @@ private constructor( responseValidation = clientOptions.responseValidation timeout = clientOptions.timeout maxRetries = clientOptions.maxRetries + logLevel = clientOptions.logLevel apiKey = clientOptions.apiKey adminApiKey = clientOptions.adminApiKey credential = clientOptions.credential.takeUnless { it === AdminApiKeyOnlyCredential } @@ -301,6 +315,9 @@ private constructor( /** * Whether to call `validate` on every response before returning it. * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * * Defaults to false, which means the shape of the response will not be validated upfront. * Instead, validation will only occur for the parts of the response that are accessed. */ @@ -342,6 +359,15 @@ private constructor( */ fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + /** + * The level at which to log request and response information. + * + * [fromEnv] will set the level from environment variables. See [LogLevel.fromEnv]. + * + * Defaults to [LogLevel.fromEnv]. + */ + fun logLevel(logLevel: LogLevel) = apply { this.logLevel = logLevel } + fun apiKey(apiKey: String?) = apply { this.apiKey = apiKey this.credential = apiKey?.let { BearerTokenCredential.create(it) } @@ -523,6 +549,7 @@ private constructor( * System properties take precedence over environment variables. */ fun fromEnv() = apply { + logLevel(LogLevel.fromEnv()) (System.getProperty("openai.baseUrl") ?: System.getenv("OPENAI_BASE_URL"))?.let { baseUrl(it) } @@ -650,7 +677,13 @@ private constructor( val wrappedHttpClient = RetryingHttpClient.builder() - .httpClient(workloadIdentityHttpClient) + .httpClient( + LoggingHttpClient.builder() + .httpClient(workloadIdentityHttpClient) + .clock(clock) + .level(logLevel) + .build() + ) .sleeper(sleeper) .clock(clock) .maxRetries(maxRetries) @@ -670,6 +703,7 @@ private constructor( responseValidation, timeout, maxRetries, + logLevel, apiKey, adminApiKey, credential, diff --git a/openai-java-core/src/main/kotlin/com/openai/core/JsonSchemaValidator.kt b/openai-java-core/src/main/kotlin/com/openai/core/JsonSchemaValidator.kt index f0f35422f..4242f73fe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/JsonSchemaValidator.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/JsonSchemaValidator.kt @@ -153,7 +153,7 @@ internal class JsonSchemaValidator private constructor() { private const val MAX_ENUM_TOTAL_STRING_LENGTH = 7_500 /** The maximum depth (number of levels) of nesting allowed in a schema. */ - private const val MAX_NESTING_DEPTH = 5 + private const val MAX_NESTING_DEPTH = 10 /** The depth value that corresponds to the root level of the schema. */ private const val ROOT_DEPTH = 0 diff --git a/openai-java-core/src/main/kotlin/com/openai/core/LogLevel.kt b/openai-java-core/src/main/kotlin/com/openai/core/LogLevel.kt new file mode 100644 index 000000000..a3b2fc1e9 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/core/LogLevel.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.core + +/** The level at which to log request and response information. */ +enum class LogLevel { + /** No logging. */ + OFF, + /** Minimal request and response summary logs. No headers or bodies are logged. */ + INFO, + /** [INFO] logs plus details about request failures. */ + ERROR, + /** + * Full request and response logs. Sensitive headers are redacted, but sensitive data in request + * and response bodies may still be visible. + */ + DEBUG; + + /** Returns whether this level is at or higher than the given [level]. */ + fun shouldLog(level: LogLevel): Boolean = ordinal >= level.ordinal + + companion object { + + /** Returns a [LogLevel] based on the `OPENAI_LOG` environment variable. */ + fun fromEnv() = + when (System.getenv("OPENAI_LOG")?.lowercase()) { + "info" -> INFO + "error" -> ERROR + "debug" -> DEBUG + else -> OFF + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt b/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt index a552585ee..4a3133fbd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/ObjectMappers.kt @@ -29,7 +29,9 @@ import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField -fun jsonMapper(): JsonMapper = +fun jsonMapper(): JsonMapper = JSON_MAPPER + +private val JSON_MAPPER: JsonMapper = JsonMapper.builder() .addModule(kotlinModule()) .addModule(Jdk8Module()) diff --git a/openai-java-core/src/main/kotlin/com/openai/core/RequestOptions.kt b/openai-java-core/src/main/kotlin/com/openai/core/RequestOptions.kt index 1d97b7bba..bf5b28b09 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/RequestOptions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/RequestOptions.kt @@ -33,6 +33,15 @@ class RequestOptions private constructor(val responseValidation: Boolean?, val t private var responseValidation: Boolean? = null private var timeout: Timeout? = null + /** + * Whether to call `validate` on the response before returning it. + * + * Setting this to `true` is _not_ forwards compatible with new types from the API for + * existing fields. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation } diff --git a/openai-java-core/src/main/kotlin/com/openai/core/Utils.kt b/openai-java-core/src/main/kotlin/com/openai/core/Utils.kt index 5edcc31b9..14744d521 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/Utils.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/Utils.kt @@ -5,6 +5,7 @@ package com.openai.core import com.openai.errors.OpenAIInvalidDataException import java.util.Collections import java.util.SortedMap +import java.util.SortedSet import java.util.concurrent.CompletableFuture import java.util.concurrent.locks.Lock @@ -16,6 +17,11 @@ internal fun T?.getOrThrow(name: String): T = internal fun List.toImmutable(): List = if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) +@JvmSynthetic +internal fun > SortedSet.toImmutable(): SortedSet = + if (isEmpty()) Collections.emptySortedSet() + else Collections.unmodifiableSortedSet(toSortedSet(comparator() ?: Comparator.naturalOrder())) + @JvmSynthetic internal fun Map.toImmutable(): Map = if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) diff --git a/openai-java-core/src/main/kotlin/com/openai/core/handlers/ErrorHandler.kt b/openai-java-core/src/main/kotlin/com/openai/core/handlers/ErrorHandler.kt index 1748c1b7d..6d6ee571c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/handlers/ErrorHandler.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/handlers/ErrorHandler.kt @@ -7,6 +7,9 @@ package com.openai.core.handlers import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponse.Handler import com.openai.errors.BadRequestException @@ -20,23 +23,26 @@ import com.openai.errors.UnprocessableEntityException import com.openai.models.ErrorObject @JvmSynthetic -internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler> { val handler = jsonHandler(jsonMapper) - return object : Handler { - override fun handle(response: HttpResponse): ErrorObject? = + return object : Handler> { + override fun handle(response: HttpResponse): JsonField = try { - handler.handle(response).get("error")?.let { - jsonMapper.readerFor(jacksonTypeRef()).readValue(it) - } + val node = handler.handle(response) + node.get("error")?.let { + jsonMapper.readerFor(jacksonTypeRef>()).readValue(it) + } ?: JsonValue.fromJsonNode(node) } catch (e: Exception) { - null + JsonMissing.of() } } } @JvmSynthetic -internal fun errorHandler(errorBodyHandler: Handler): Handler = +internal fun errorHandler( + errorBodyHandler: Handler> +): Handler = object : Handler { override fun handle(response: HttpResponse): HttpResponse = when (val statusCode = response.statusCode()) { diff --git a/openai-java-core/src/main/kotlin/com/openai/core/handlers/SseHandler.kt b/openai-java-core/src/main/kotlin/com/openai/core/handlers/SseHandler.kt index 5a0a5ebc0..8907903cc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/core/handlers/SseHandler.kt +++ b/openai-java-core/src/main/kotlin/com/openai/core/handlers/SseHandler.kt @@ -7,6 +7,8 @@ package com.openai.core.handlers import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.JsonField +import com.openai.core.JsonMissing import com.openai.core.http.HttpResponse import com.openai.core.http.HttpResponse.Handler import com.openai.core.http.SseMessage @@ -48,10 +50,10 @@ internal fun sseHandler(jsonMapper: JsonMapper): Handler()) - .readValue(it) + .readerFor(jacksonTypeRef>()) + .readValue>(it) } catch (e: Exception) { - null + JsonMissing.of() } ) .build() diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/LoggingHttpClient.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/LoggingHttpClient.kt new file mode 100644 index 000000000..464a6f690 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/LoggingHttpClient.kt @@ -0,0 +1,628 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.core.http + +import com.openai.core.LogLevel +import com.openai.core.RequestOptions +import com.openai.core.checkRequired +import com.openai.core.toImmutable +import java.io.ByteArrayOutputStream +import java.io.InputStream +import java.io.OutputStream +import java.nio.ByteBuffer +import java.nio.charset.CharacterCodingException +import java.nio.charset.Charset +import java.nio.charset.CharsetDecoder +import java.nio.charset.CodingErrorAction +import java.nio.charset.StandardCharsets +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.util.SortedSet +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletionException +import kotlin.time.toKotlinDuration + +/** A wrapper [HttpClient] around [httpClient] that logs request and response information. */ +class LoggingHttpClient +private constructor( + /** The underlying [HttpClient] for making requests. */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Sensitive headers to redact from logs. + * + * Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`. + */ + @get:JvmName("redactedHeaders") val redactedHeaders: SortedSet, + /** + * The clock to use for measuring request and response durations. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + /** + * The log level to use. + * + * Pass [LogLevel.fromEnv] to read from environment variables. + */ + @get:JvmName("level") val level: LogLevel, +) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val loggingRequest = logRequest(request) + + val before = OffsetDateTime.now(clock) + val response = + try { + httpClient.execute(loggingRequest, requestOptions) + } catch (e: Throwable) { + logFailure(e, Duration.between(before, OffsetDateTime.now(clock))) + throw e + } + + val took = Duration.between(before, OffsetDateTime.now(clock)) + return logResponse(response, took) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val loggingRequest = logRequest(request) + + val before = OffsetDateTime.now(clock) + val future = + try { + httpClient.executeAsync(loggingRequest, requestOptions) + } catch (e: Throwable) { + logFailure(e, Duration.between(before, OffsetDateTime.now(clock))) + throw e + } + return future.handle { response, error -> + val took = Duration.between(before, OffsetDateTime.now(clock)) + if (error != null) { + logFailure(unwrapCompletionException(error), took) + throw error + } + logResponse(response, took) + } + } + + private fun logRequest(request: HttpRequest): HttpRequest { + if (!level.shouldLog(LogLevel.INFO)) { + return request + } + + System.err.println( + buildString { + append("--> ${request.method} ${request.url()}") + request.body?.let { + val length = it.contentLength() + append(if (length >= 0) " ($length-byte body)" else " (unknown-length body)") + } + } + ) + + if (!level.shouldLog(LogLevel.DEBUG)) { + return request + } + + logHeaders(request.headers) + + if (request.body == null) { + System.err.println("--> END ${request.method}") + System.err.println() + return request + } + + return request + .toBuilder() + .body(LoggingHttpRequestBody(request.method, request.body)) + .build() + } + + private fun logResponse(response: HttpResponse, took: Duration): HttpResponse { + if (!level.shouldLog(LogLevel.INFO)) { + return response + } + + val contentLength = response.headers().values("Content-Length").firstOrNull()?.toIntOrNull() + System.err.println( + "<-- ${response.statusCode()} (${ + buildString { + append(took.format()) + contentLength?.let { append(", $contentLength-byte body") } + } + })" + ) + + if (!level.shouldLog(LogLevel.DEBUG)) { + return response + } + + logHeaders(response.headers()) + return LoggingHttpResponse(response) + } + + private fun logFailure(error: Throwable, took: Duration) { + if (!level.shouldLog(LogLevel.ERROR)) { + return + } + + System.err.println( + buildString { + append("<-- !! ${error.javaClass.simpleName}") + error.message?.let { append(": $it") } + append(" (${took.format()})") + } + ) + } + + private fun unwrapCompletionException(error: Throwable): Throwable = + if (error is CompletionException && error.cause != null) error.cause!! else error + + private fun logHeaders(headers: Headers) = + headers.names().forEach { name -> + headers.values(name).forEach { value -> + System.err.println("$name: ${if (redactedHeaders.contains(name)) "██" else value}") + } + } + + override fun close() = httpClient.close() + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [LoggingHttpClient]. + * + * The following fields are required: + * ```java + * .httpClient() + * .level() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LoggingHttpClient]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var redactedHeaders: Set = + setOf("authorization", "api-key", "x-api-key", "cookie", "set-cookie") + private var clock: Clock = Clock.systemUTC() + private var level: LogLevel? = null + + @JvmSynthetic + internal fun from(loggingHttpClient: LoggingHttpClient) = apply { + httpClient = loggingHttpClient.httpClient + redactedHeaders = loggingHttpClient.redactedHeaders + clock = loggingHttpClient.clock + level = loggingHttpClient.level + } + + /** The underlying [HttpClient] for making requests. */ + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + /** + * Sensitive headers to redact from logs. + * + * Defaults to `Set.of("authorization", "api-key", "x-api-key", "cookie", "set-cookie")`. + */ + fun redactedHeaders(redactedHeaders: Set) = apply { + this.redactedHeaders = redactedHeaders + } + + /** + * The clock to use for measuring request and response durations. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The log level to use. + * + * Pass [LogLevel.fromEnv] to read from environment variables. + */ + fun level(level: LogLevel) = apply { this.level = level } + + /** + * Returns an immutable instance of [LoggingHttpClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .level() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LoggingHttpClient = + LoggingHttpClient( + checkRequired("httpClient", httpClient), + redactedHeaders.toSortedSet(String.CASE_INSENSITIVE_ORDER).toImmutable(), + clock, + checkRequired("level", level), + ) + } +} + +/** + * An [HttpRequestBody] wrapper that delegates to [body] while also logging line by line as it's + * written. + * + * The logging occurs in a streaming manner with minimal buffering. + */ +private class LoggingHttpRequestBody( + private val method: HttpMethod, + private val body: HttpRequestBody, +) : HttpRequestBody { + + private val charset by lazy { parseCharset(body.contentType()) } + + override fun writeTo(outputStream: OutputStream) { + val loggingOutputStream = LoggingOutputStream(outputStream, charset) + body.writeTo(loggingOutputStream) + + loggingOutputStream.flush() + System.err.println("--> END $method (${loggingOutputStream.writeCount()}-byte body)") + System.err.println() + } + + override fun contentType(): String? = body.contentType() + + override fun contentLength(): Long = body.contentLength() + + override fun repeatable(): Boolean = body.repeatable() + + override fun close() = body.close() +} + +/** + * An [OutputStream] wrapper that delegates to [outputStream] while also logging bytes line by line + * as it's written to. + * + * The written content is assumed to be in the given [charset] and the logging occurs in a streaming + * manner with minimal buffering. + */ +private class LoggingOutputStream(private val outputStream: OutputStream, charset: Charset?) : + OutputStream() { + + private val buffer = LoggingBuffer(charset) + + fun writeCount() = buffer.writeCount() + + override fun write(b: Int) { + outputStream.write(b) + buffer.write(b) + } + + override fun write(b: ByteArray, off: Int, len: Int) { + outputStream.write(b, off, len) + for (i in off until off + len) { + buffer.write(b[i].toInt() and 0xFF) + } + } + + /** Prints any currently buffered content. */ + override fun flush() { + buffer.flush() + outputStream.flush() + } + + override fun close() = outputStream.close() +} + +/** + * An [HttpResponse] wrapper that delegates to [response] while also logging line-by-line as it's + * read. + * + * The logging occurs in a streaming manner with minimal buffering. + */ +private class LoggingHttpResponse(private val response: HttpResponse) : HttpResponse { + + private val loggingBody: Lazy = lazy { + LoggingInputStream( + response.body(), + parseCharset(response.headers().values("Content-Type").firstOrNull()), + ) + } + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = loggingBody.value + + override fun close() { + if (loggingBody.isInitialized()) { + loggingBody.value.close() + } + response.close() + } +} + +/** + * An [InputStream] wrapper that delegates to [inputStream] while also logging bytes line by line as + * it's read. + * + * The contents of [inputStream] are assumed to be in the given [charset] and the logging occurs in + * a streaming manner with minimal buffering. + */ +private class LoggingInputStream(private val inputStream: InputStream, charset: Charset?) : + InputStream() { + + private var isDone = false + private val buffer = LoggingBuffer(charset) + + override fun read(): Int { + if (isDone) { + return -1 + } + + val b = inputStream.read() + + if (b == -1) { + markDone() + return b + } + + buffer.write(b) + return b + } + + override fun read(b: ByteArray, off: Int, len: Int): Int { + if (isDone) { + return -1 + } + + val bytesRead = inputStream.read(b, off, len) + + if (bytesRead == -1) { + markDone() + return bytesRead + } + + for (i in off until off + bytesRead) { + buffer.write(b[i].toInt() and 0xFF) + } + return bytesRead + } + + override fun close() { + if (!isDone) { + markDone(closedEarly = true) + } + inputStream.close() + } + + private fun markDone(closedEarly: Boolean = false) { + isDone = true + buffer.flush() + val suffix = if (closedEarly) ", closed early" else "" + System.err.println("<-- END HTTP (${buffer.writeCount()}-byte body$suffix)") + System.err.println() + } +} + +/** + * A byte buffer that prints line by line, using the given [charset], as bytes are written to it. + * + * When [charset] is `null`, the buffer performs an upfront check to detect binary content. If + * non-whitespace ISO control characters are found in the first [PROBABLY_UTF8_CODE_POINT_LIMIT] + * code points, body logging is suppressed entirely. + */ +private class LoggingBuffer(charset: Charset?) { + + private val charset = charset ?: StandardCharsets.UTF_8 + + private val decoder: CharsetDecoder = + this.charset + .newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + private var writeCount = 0 + private val buffer = ByteArrayOutputStream(128) + + /** + * Whether logging has been suppressed because the content doesn't appear to be readable text. + * + * This is only set when [charset] is `null` and the content fails the [isProbablyUtf8] check. + */ + private var suppressed = false + + /** + * Bytes accumulated for the [isProbablyUtf8] check before any lines are printed. + * + * Once the check passes (or [charset] is non-null), this is set to `null` and bytes flow + * directly to [buffer]. + */ + private var prefetchBuffer: ByteArrayOutputStream? = + if (charset != null) null else ByteArrayOutputStream(128) + + fun writeCount() = writeCount + + fun write(b: Int) { + if (writeCount == 0) { + // Print a newline before we start printing anything to separate the printed content + // from previous content. + System.err.println() + } + + writeCount++ + + if (suppressed) { + return + } + + val prefetch = prefetchBuffer + if (prefetch != null) { + prefetch.write(b) + // Continue accumulating until we have enough bytes to decide. + if (prefetch.size() < PROBABLY_UTF8_BYTE_LIMIT && b != '\n'.code) { + return + } + // We have enough bytes. Check if the content is probably UTF-8. + prefetchBuffer = null + val bytes = prefetch.toByteArray() + if (!isProbablyUtf8(bytes)) { + suppressed = true + System.err.println("(binary body omitted)") + return + } + // Content looks like UTF-8. Feed the accumulated bytes into the normal buffer. + for (byte in bytes) { + writeToBuffer(byte.toInt() and 0xFF) + } + return + } + + writeToBuffer(b) + } + + private fun writeToBuffer(b: Int) { + if (b == '\n'.code) { + flush() + return + } + + buffer.write(b) + } + + /** Prints any currently buffered content. */ + fun flush() { + if (suppressed) { + return + } + + // If we still have a prefetch buffer when flush is called (body was shorter than the + // limit), run the check now. + val prefetch = prefetchBuffer + if (prefetch != null) { + prefetchBuffer = null + val bytes = prefetch.toByteArray() + if (bytes.isEmpty()) { + return + } + if (!isProbablyUtf8(bytes)) { + suppressed = true + System.err.println("(binary body omitted)") + return + } + for (byte in bytes) { + writeToBuffer(byte.toInt() and 0xFF) + } + } + + if (buffer.size() == 0) { + return + } + + val line = + try { + decoder.decode(ByteBuffer.wrap(buffer.toByteArray())) + } catch (e: CharacterCodingException) { + "(omitted line is not valid $charset)" + } + buffer.reset() + System.err.println(line) + } +} + +/** The maximum number of code points to sample when checking if content is probably UTF-8. */ +private const val PROBABLY_UTF8_CODE_POINT_LIMIT = 64 + +/** + * The maximum number of bytes to accumulate before running the [isProbablyUtf8] check. UTF-8 code + * points are at most 4 bytes, so this accommodates [PROBABLY_UTF8_CODE_POINT_LIMIT] code points. + */ +private const val PROBABLY_UTF8_BYTE_LIMIT = PROBABLY_UTF8_CODE_POINT_LIMIT * 4 + +/** + * Returns `true` if the given [bytes] probably contain human-readable UTF-8 text. + * + * Decodes up to [PROBABLY_UTF8_CODE_POINT_LIMIT] code points and returns `false` if any + * non-whitespace ISO control characters are found, or if the bytes are not valid UTF-8. + */ +private fun isProbablyUtf8(bytes: ByteArray): Boolean { + try { + val decoder = + StandardCharsets.UTF_8.newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + val charBuffer = decoder.decode(ByteBuffer.wrap(bytes)) + var codePointCount = 0 + var i = 0 + while (i < charBuffer.length && codePointCount < PROBABLY_UTF8_CODE_POINT_LIMIT) { + val codePoint = Character.codePointAt(charBuffer, i) + if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) { + return false + } + i += Character.charCount(codePoint) + codePointCount++ + } + return true + } catch (e: CharacterCodingException) { + return false + } +} + +/** Returns the [Charset] in the given [contentType] string, or `null` if unspecified. */ +private fun parseCharset(contentType: String?): Charset? = + contentType + ?.split(";") + ?.drop(1) + ?.map { it.trim() } + ?.firstOrNull { it.startsWith("charset=", ignoreCase = true) } + ?.substringAfter("=") + ?.trim() + ?.removeSurrounding("\"") + ?.let { runCatching { charset(it) }.getOrNull() } + +/** Formats the [Duration] into a string like "1m 40s 467ms". */ +private fun Duration.format(): String = + toKotlinDuration().toComponents { days, hours, minutes, seconds, nanoseconds -> + buildString { + val milliseconds = nanoseconds / 1_000_000 + if (days > 0) { + append("${days}d") + } + if (hours > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${hours}h") + } + if (minutes > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${minutes}m") + } + if (seconds > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${seconds}s") + } + if (milliseconds > 0) { + if (isNotEmpty()) { + append(" ") + } + append("${milliseconds}ms") + } + + if (isEmpty()) { + append("0s") + } + } + } diff --git a/openai-java-core/src/main/kotlin/com/openai/core/http/ProxyAuthenticator.kt b/openai-java-core/src/main/kotlin/com/openai/core/http/ProxyAuthenticator.kt new file mode 100644 index 000000000..254976690 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/core/http/ProxyAuthenticator.kt @@ -0,0 +1,59 @@ +package com.openai.core.http + +import java.net.Proxy +import java.nio.charset.Charset +import java.nio.charset.StandardCharsets +import java.util.Base64 +import java.util.Optional + +/** + * Provides credentials when an HTTP proxy responds with `407 Proxy Authentication Required`. + * + * Implementations inspect the 407 [response] (typically its `Proxy-Authenticate` header) and return + * the request to retry with a `Proxy-Authorization` header set, or [Optional.empty] to abandon + * authentication and surface the 407 to the caller. + * + * Implementations must be thread-safe; they may be invoked concurrently from multiple HTTP calls. + */ +fun interface ProxyAuthenticator { + + /** + * @param proxy the proxy that produced the challenge, or [Proxy.NO_PROXY] if the route is not + * yet established + * @param request the request that produced [response] + * @param response the 407 challenge response + * @return the retry request to send (typically [request] with a `Proxy-Authorization` header + * added), or [Optional.empty] to abandon authentication + */ + fun authenticate( + proxy: Proxy, + request: HttpRequest, + response: HttpResponse, + ): Optional + + companion object { + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the ISO-8859-1 + * charset. + */ + @JvmStatic + fun basic(username: String, password: String): ProxyAuthenticator = + basic(username, password, StandardCharsets.ISO_8859_1) + + /** + * A [ProxyAuthenticator] that uses RFC 7617 Basic authentication with the given [charset]. + */ + @JvmStatic + fun basic(username: String, password: String, charset: Charset): ProxyAuthenticator { + val token = + Base64.getEncoder().encodeToString("$username:$password".toByteArray(charset)) + val headerValue = "Basic $token" + return ProxyAuthenticator { _, request, _ -> + Optional.of( + request.toBuilder().putHeader("Proxy-Authorization", headerValue).build() + ) + } + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/BadRequestException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/BadRequestException.kt index bf233b5aa..7bdb7f4cb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/BadRequestException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/BadRequestException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -14,20 +15,27 @@ import kotlin.jvm.optionals.getOrNull class BadRequestException private constructor( private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("400: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "400: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun statusCode(): Int = 400 override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun headers(): Headers = headers @@ -50,7 +58,7 @@ private constructor( class Builder internal constructor() { private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -62,11 +70,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/InternalServerException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/InternalServerException.kt index 63e27034d..d573588d4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/InternalServerException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/InternalServerException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -15,18 +16,25 @@ class InternalServerException private constructor( private val statusCode: Int, private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("$statusCode: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "$statusCode: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun statusCode(): Int = statusCode @@ -53,7 +61,7 @@ private constructor( private var statusCode: Int? = null private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -68,11 +76,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/NotFoundException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/NotFoundException.kt index bc4ae60d5..457b0503c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/NotFoundException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/NotFoundException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -14,20 +15,27 @@ import kotlin.jvm.optionals.getOrNull class NotFoundException private constructor( private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("404: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "404: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun statusCode(): Int = 404 override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun headers(): Headers = headers @@ -50,7 +58,7 @@ private constructor( class Builder internal constructor() { private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -62,11 +70,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/PermissionDeniedException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/PermissionDeniedException.kt index 03a3999f4..c9ae8beec 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/PermissionDeniedException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/PermissionDeniedException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -14,20 +15,27 @@ import kotlin.jvm.optionals.getOrNull class PermissionDeniedException private constructor( private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("403: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "403: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun statusCode(): Int = 403 override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun headers(): Headers = headers @@ -50,7 +58,7 @@ private constructor( class Builder internal constructor() { private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -62,11 +70,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/RateLimitException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/RateLimitException.kt index 02ae02bb6..8425abb2b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/RateLimitException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/RateLimitException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -14,20 +15,27 @@ import kotlin.jvm.optionals.getOrNull class RateLimitException private constructor( private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("429: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "429: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun statusCode(): Int = 429 override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun headers(): Headers = headers @@ -50,7 +58,7 @@ private constructor( class Builder internal constructor() { private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -62,11 +70,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/SseException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/SseException.kt index b4488d5d5..74f969c25 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/SseException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/SseException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -15,18 +16,25 @@ class SseException private constructor( private val statusCode: Int, private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("$statusCode: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "$statusCode: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun statusCode(): Int = statusCode @@ -53,7 +61,7 @@ private constructor( private var statusCode: Int? = null private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -68,11 +76,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/UnauthorizedException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/UnauthorizedException.kt index e8eb5a2cb..e9ae80302 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/UnauthorizedException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/UnauthorizedException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -14,20 +15,27 @@ import kotlin.jvm.optionals.getOrNull class UnauthorizedException private constructor( private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("401: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "401: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun statusCode(): Int = 401 override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun headers(): Headers = headers @@ -50,7 +58,7 @@ private constructor( class Builder internal constructor() { private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -62,11 +70,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/UnexpectedStatusCodeException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/UnexpectedStatusCodeException.kt index d4b32160a..16627f1f3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/UnexpectedStatusCodeException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/UnexpectedStatusCodeException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -15,18 +16,25 @@ class UnexpectedStatusCodeException private constructor( private val statusCode: Int, private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("$statusCode: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "$statusCode: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun statusCode(): Int = statusCode @@ -54,7 +62,7 @@ private constructor( private var statusCode: Int? = null private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -69,11 +77,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/errors/UnprocessableEntityException.kt b/openai-java-core/src/main/kotlin/com/openai/errors/UnprocessableEntityException.kt index 42a5a7ca2..f23316843 100644 --- a/openai-java-core/src/main/kotlin/com/openai/errors/UnprocessableEntityException.kt +++ b/openai-java-core/src/main/kotlin/com/openai/errors/UnprocessableEntityException.kt @@ -2,6 +2,7 @@ package com.openai.errors +import com.openai.core.JsonField import com.openai.core.JsonMissing import com.openai.core.JsonValue import com.openai.core.checkRequired @@ -14,20 +15,27 @@ import kotlin.jvm.optionals.getOrNull class UnprocessableEntityException private constructor( private val headers: Headers, - private val error: ErrorObject?, + private val error: JsonField, cause: Throwable?, -) : OpenAIServiceException("422: ${error?._message()}", cause) { +) : + OpenAIServiceException( + "422: ${error.asKnown().getOrNull()?._message()?.asKnown()?.getOrNull() ?: (if (error.isMissing()) "Unknown" else jsonMapper().writeValueAsString(error))}", + cause, + ) { override fun statusCode(): Int = 422 override fun body(): JsonValue = - error?.let { JsonValue.fromJsonNode(jsonMapper().valueToTree(it)) } ?: JsonMissing.of() + if (error.isMissing()) JsonMissing.of() + else JsonValue.fromJsonNode(jsonMapper().valueToTree(error)) - override fun code(): Optional = Optional.ofNullable(error?.code()?.getOrNull()) + override fun code(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.code()?.getOrNull()) - override fun param(): Optional = Optional.ofNullable(error?.param()?.getOrNull()) + override fun param(): Optional = + Optional.ofNullable(error.asKnown().getOrNull()?.param()?.getOrNull()) - override fun type(): Optional = Optional.ofNullable(error?.type()) + override fun type(): Optional = Optional.ofNullable(error.asKnown().getOrNull()?.type()) override fun headers(): Headers = headers @@ -50,7 +58,7 @@ private constructor( class Builder internal constructor() { private var headers: Headers? = null - private var error: ErrorObject? = null + private var error: JsonField = JsonMissing.of() private var cause: Throwable? = null @JvmSynthetic @@ -62,11 +70,13 @@ private constructor( fun headers(headers: Headers) = apply { this.headers = headers } - fun error(error: ErrorObject?) = apply { this.error = error } + fun error(error: ErrorObject?) = error(JsonField.ofNullable(error)) /** Alias for calling [Builder.error] with `error.orElse(null)`. */ fun error(error: Optional) = error(error.getOrNull()) + fun error(error: JsonField) = apply { this.error = error } + fun cause(cause: Throwable?) = apply { this.cause = cause } /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ diff --git a/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt b/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt index 318a68e6e..60e555625 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/AllModels.kt @@ -52,6 +52,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = allModels.accept(new AllModels.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -62,6 +91,14 @@ private constructor( 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(): AllModels = apply { if (validated) { return@apply @@ -380,6 +417,15 @@ private constructor( 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(): ResponsesOnlyModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt index 6ae3ba181..16bf07847 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatModel.kt @@ -550,6 +550,14 @@ class ChatModel @JsonCreator private constructor(private val value: JsonField = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = value.accept(new Value.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -509,6 +555,15 @@ private constructor( 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(): Value = apply { if (validated) { return@apply @@ -709,6 +764,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = comparisonFilterValueItem.accept(new ComparisonFilterValueItem.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -718,6 +803,16 @@ private constructor( 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(): ComparisonFilterValueItem = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/CompoundFilter.kt b/openai-java-core/src/main/kotlin/com/openai/models/CompoundFilter.kt index 36e7ce715..84f7ce186 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/CompoundFilter.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/CompoundFilter.kt @@ -203,6 +203,14 @@ private constructor( 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(): CompoundFilter = apply { if (validated) { return@apply @@ -266,6 +274,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = filter.accept(new Filter.Visitor>() { + * @Override + * public Optional visitComparison(ComparisonFilter comparison) { + * return Optional.of(comparison.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { comparison != null -> visitor.visitComparison(comparison) @@ -275,6 +312,15 @@ private constructor( 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(): Filter = apply { if (validated) { return@apply @@ -510,6 +556,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/CustomToolInputFormat.kt b/openai-java-core/src/main/kotlin/com/openai/models/CustomToolInputFormat.kt index 1f0d125dc..0d2d1170f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/CustomToolInputFormat.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/CustomToolInputFormat.kt @@ -56,6 +56,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = customToolInputFormat.accept(new CustomToolInputFormat.Visitor>() { + * @Override + * public Optional visitText(JsonValue text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -65,6 +94,14 @@ private constructor( 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(): CustomToolInputFormat = apply { if (validated) { return@apply @@ -397,6 +434,15 @@ private constructor( 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(): Grammar = apply { if (validated) { return@apply @@ -524,6 +570,16 @@ private constructor( 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(): Syntax = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ErrorObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/ErrorObject.kt index 88cf53223..14773f348 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ErrorObject.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ErrorObject.kt @@ -225,6 +225,14 @@ private constructor( 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(): ErrorObject = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt b/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt index e30b1e4de..8087c7d3e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/FunctionDefinition.kt @@ -274,6 +274,14 @@ private constructor( 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(): FunctionDefinition = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/FunctionParameters.kt b/openai-java-core/src/main/kotlin/com/openai/models/FunctionParameters.kt index cac22f8ff..02ac1b915 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/FunctionParameters.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/FunctionParameters.kt @@ -76,6 +76,14 @@ private constructor( 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(): FunctionParameters = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/OAuthErrorCode.kt b/openai-java-core/src/main/kotlin/com/openai/models/OAuthErrorCode.kt index 704517d03..ba07f450f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/OAuthErrorCode.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/OAuthErrorCode.kt @@ -94,6 +94,14 @@ class OAuthErrorCode @JsonCreator private constructor(private val value: JsonFie 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(): OAuthErrorCode = apply { if (validated) { return@apply 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 685342fb2..224a76108 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 @@ -248,6 +248,14 @@ private constructor( 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(): Reasoning = apply { if (validated) { return@apply @@ -382,6 +390,15 @@ private constructor( 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(): GenerateSummary = apply { if (validated) { return@apply @@ -520,6 +537,15 @@ private constructor( 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(): Summary = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt b/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt index 183297e01..0bead0c0a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ReasoningEffort.kt @@ -131,6 +131,14 @@ class ReasoningEffort @JsonCreator private constructor(private val value: JsonFi 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(): ReasoningEffort = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonObject.kt index a67417617..78df68e0a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonObject.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonObject.kt @@ -117,6 +117,14 @@ private constructor( 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(): ResponseFormatJsonObject = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonSchema.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonSchema.kt index 1c18860fd..be7db8d1c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonSchema.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatJsonSchema.kt @@ -174,6 +174,14 @@ private constructor( 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(): ResponseFormatJsonSchema = apply { if (validated) { return@apply @@ -455,6 +463,15 @@ private constructor( 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(): JsonSchema = apply { if (validated) { return@apply @@ -553,6 +570,16 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatText.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatText.kt index cd8a35d81..b64967b33 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatText.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatText.kt @@ -113,6 +113,14 @@ private constructor( 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(): ResponseFormatText = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextGrammar.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextGrammar.kt index 556dcb6c7..d40fd646b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextGrammar.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextGrammar.kt @@ -166,6 +166,14 @@ private constructor( 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(): ResponseFormatTextGrammar = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextPython.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextPython.kt index edfa99ea6..87116f2da 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextPython.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponseFormatTextPython.kt @@ -117,6 +117,14 @@ private constructor( 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(): ResponseFormatTextPython = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt index ba197e098..cafdcc85e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ResponsesModel.kt @@ -51,6 +51,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = responsesModel.accept(new ResponsesModel.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -61,6 +90,14 @@ private constructor( 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(): ResponsesModel = apply { if (validated) { return@apply @@ -379,6 +416,15 @@ private constructor( 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(): ResponsesOnlyModel = apply { if (validated) { return@apply 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 e6806ea5f..feb025044 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 @@ -345,6 +345,14 @@ private constructor( 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(): AdminApiKey = apply { if (validated) { return@apply @@ -643,6 +651,15 @@ private constructor( 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(): Owner = apply { if (validated) { return@apply 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 05770b2f4..f40398276 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 @@ -348,6 +348,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply 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 b8f53d7ce..c7acdc7ed 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 @@ -392,6 +392,14 @@ private constructor( 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(): AdminApiKeyCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyDeleteResponse.kt index 24f6cc024..5524cbe80 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyDeleteResponse.kt @@ -187,6 +187,14 @@ private constructor( 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(): AdminApiKeyDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponse.kt index 3956d0699..e03698123 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListPageResponse.kt @@ -268,6 +268,14 @@ private constructor( 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(): AdminApiKeyListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListParams.kt index d60f3ee93..f5e5d5a5b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/adminapikeys/AdminApiKeyListParams.kt @@ -304,6 +304,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponse.kt index 314f496d0..9e1d17adb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/auditlogs/AuditLogListPageResponse.kt @@ -270,6 +270,14 @@ private constructor( 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(): AuditLogListPageResponse = apply { if (validated) { return@apply 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 e9ae6df46..ad4518903 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 @@ -981,6 +981,15 @@ private constructor( 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(): EventType = apply { if (validated) { return@apply 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 69361e29a..851ac96ed 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 @@ -2166,6 +2166,14 @@ private constructor( 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(): AuditLogListResponse = apply { if (validated) { return@apply @@ -2672,6 +2680,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -2871,6 +2888,15 @@ private constructor( 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(): Actor = apply { if (validated) { return@apply @@ -3107,6 +3133,16 @@ private constructor( 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(): ApiKey = apply { if (validated) { return@apply @@ -3245,6 +3281,16 @@ private constructor( 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(): ServiceAccount = apply { if (validated) { return@apply @@ -3381,6 +3427,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -3555,6 +3611,16 @@ private constructor( 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(): User = apply { if (validated) { return@apply @@ -3764,6 +3830,16 @@ private constructor( 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(): Session = apply { if (validated) { return@apply @@ -3929,6 +4005,16 @@ private constructor( 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(): User = apply { if (validated) { return@apply @@ -4088,6 +4174,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -4279,6 +4375,15 @@ private constructor( 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(): ApiKeyCreated = apply { if (validated) { return@apply @@ -4429,6 +4534,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -4590,6 +4705,15 @@ private constructor( 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(): ApiKeyDeleted = apply { if (validated) { return@apply @@ -4773,6 +4897,15 @@ private constructor( 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(): ApiKeyUpdated = apply { if (validated) { return@apply @@ -4924,6 +5057,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -5119,6 +5262,15 @@ private constructor( 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(): CertificateCreated = apply { if (validated) { return@apply @@ -5334,6 +5486,15 @@ private constructor( 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(): CertificateDeleted = apply { if (validated) { return@apply @@ -5518,6 +5679,15 @@ private constructor( 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(): CertificateUpdated = apply { if (validated) { return@apply @@ -5687,6 +5857,15 @@ private constructor( 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(): CertificatesActivated = apply { if (validated) { return@apply @@ -5847,6 +6026,16 @@ private constructor( 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(): Certificate = apply { if (validated) { return@apply @@ -6034,6 +6223,15 @@ private constructor( 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(): CertificatesDeactivated = apply { if (validated) { return@apply @@ -6194,6 +6392,16 @@ private constructor( 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(): Certificate = apply { if (validated) { return@apply @@ -6396,6 +6604,15 @@ private constructor( 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(): CheckpointPermissionCreated = apply { if (validated) { return@apply @@ -6572,6 +6789,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -6745,6 +6972,15 @@ private constructor( 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(): CheckpointPermissionDeleted = apply { if (validated) { return@apply @@ -6907,6 +7143,15 @@ private constructor( 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(): ExternalKeyRegistered = apply { if (validated) { return@apply @@ -7051,6 +7296,15 @@ private constructor( 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(): ExternalKeyRemoved = apply { if (validated) { return@apply @@ -7224,6 +7478,15 @@ private constructor( 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(): GroupCreated = apply { if (validated) { return@apply @@ -7359,6 +7622,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -7521,6 +7794,15 @@ private constructor( 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(): GroupDeleted = apply { if (validated) { return@apply @@ -7703,6 +7985,15 @@ private constructor( 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(): GroupUpdated = apply { if (validated) { return@apply @@ -7840,6 +8131,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -8004,6 +8305,15 @@ private constructor( 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(): InviteAccepted = apply { if (validated) { return@apply @@ -8146,6 +8456,15 @@ private constructor( 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(): InviteDeleted = apply { if (validated) { return@apply @@ -8319,6 +8638,15 @@ private constructor( 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(): InviteSent = apply { if (validated) { return@apply @@ -8480,6 +8808,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -8669,6 +9007,15 @@ private constructor( 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(): IpAllowlistConfigActivated = apply { if (validated) { return@apply @@ -8828,6 +9175,16 @@ private constructor( 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(): Config = apply { if (validated) { return@apply @@ -9016,6 +9373,15 @@ private constructor( 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(): IpAllowlistConfigDeactivated = apply { if (validated) { return@apply @@ -9175,6 +9541,16 @@ private constructor( 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(): Config = apply { if (validated) { return@apply @@ -9425,6 +9801,15 @@ private constructor( 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(): IpAllowlistCreated = apply { if (validated) { return@apply @@ -9663,6 +10048,15 @@ private constructor( 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(): IpAllowlistDeleted = apply { if (validated) { return@apply @@ -9869,6 +10263,15 @@ private constructor( 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(): IpAllowlistUpdated = apply { if (validated) { return@apply @@ -10056,6 +10459,15 @@ private constructor( 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(): LoginFailed = apply { if (validated) { return@apply @@ -10246,6 +10658,15 @@ private constructor( 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(): LogoutFailed = apply { if (validated) { return@apply @@ -10436,6 +10857,15 @@ private constructor( 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(): OrganizationUpdated = apply { if (validated) { return@apply @@ -10830,6 +11260,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -11058,6 +11498,15 @@ private constructor( 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(): Project = apply { if (validated) { return@apply @@ -11204,6 +11653,15 @@ private constructor( 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(): ProjectArchived = apply { if (validated) { return@apply @@ -11378,6 +11836,15 @@ private constructor( 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(): ProjectCreated = apply { if (validated) { return@apply @@ -11539,6 +12006,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -11704,6 +12181,15 @@ private constructor( 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(): ProjectDeleted = apply { if (validated) { return@apply @@ -11887,6 +12373,15 @@ private constructor( 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(): ProjectUpdated = apply { if (validated) { return@apply @@ -12019,6 +12514,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -12183,6 +12688,15 @@ private constructor( 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(): RateLimitDeleted = apply { if (validated) { return@apply @@ -12366,6 +12880,15 @@ private constructor( 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(): RateLimitUpdated = apply { if (validated) { return@apply @@ -12724,6 +13247,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -13072,6 +13605,15 @@ private constructor( 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(): RoleAssignmentCreated = apply { if (validated) { return@apply @@ -13395,6 +13937,15 @@ private constructor( 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(): RoleAssignmentDeleted = apply { if (validated) { return@apply @@ -13723,6 +14274,15 @@ private constructor( 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 @@ -13881,6 +14441,15 @@ private constructor( 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 @@ -14063,6 +14632,15 @@ private constructor( 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(): RoleUpdated = apply { if (validated) { return@apply @@ -14453,6 +15031,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -14645,6 +15233,15 @@ private constructor( 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(): ScimDisabled = apply { if (validated) { return@apply @@ -14786,6 +15383,15 @@ private constructor( 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(): ScimEnabled = apply { if (validated) { return@apply @@ -14961,6 +15567,15 @@ private constructor( 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(): ServiceAccountCreated = apply { if (validated) { return@apply @@ -15091,6 +15706,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -15254,6 +15879,15 @@ private constructor( 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(): ServiceAccountDeleted = apply { if (validated) { return@apply @@ -15439,6 +16073,15 @@ private constructor( 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(): ServiceAccountUpdated = apply { if (validated) { return@apply @@ -15571,6 +16214,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply @@ -15765,6 +16418,15 @@ private constructor( 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(): UserAdded = apply { if (validated) { return@apply @@ -15895,6 +16557,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -16055,6 +16727,15 @@ private constructor( 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(): UserDeleted = apply { if (validated) { return@apply @@ -16237,6 +16918,15 @@ private constructor( 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(): UserUpdated = apply { if (validated) { return@apply @@ -16369,6 +17059,16 @@ private constructor( 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(): ChangesRequested = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/Certificate.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/Certificate.kt index 7a574e0b1..006b12dee 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/Certificate.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/Certificate.kt @@ -324,6 +324,14 @@ private constructor( 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(): Certificate = apply { if (validated) { return@apply @@ -523,6 +531,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply @@ -677,6 +694,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivatePageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivatePageResponse.kt index ca98c0ad6..81f58e6f6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivatePageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivatePageResponse.kt @@ -184,6 +184,14 @@ private constructor( 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(): CertificateActivatePageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateParams.kt index 1a7cc6abd..3b57b19d6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateParams.kt @@ -390,6 +390,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateResponse.kt index f0d91f36f..47d41c0ac 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateActivateResponse.kt @@ -307,6 +307,14 @@ private constructor( 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(): CertificateActivateResponse = apply { if (validated) { return@apply @@ -479,6 +487,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateCreateParams.kt index dda207632..32ab58ff9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateCreateParams.kt @@ -429,6 +429,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivatePageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivatePageResponse.kt index c13084861..aee9f2cfc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivatePageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivatePageResponse.kt @@ -184,6 +184,14 @@ private constructor( 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(): CertificateDeactivatePageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateParams.kt index 195a18e06..553388411 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateParams.kt @@ -390,6 +390,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateResponse.kt index 917395c3d..0ae4ac038 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeactivateResponse.kt @@ -308,6 +308,14 @@ private constructor( 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(): CertificateDeactivateResponse = apply { if (validated) { return@apply @@ -480,6 +488,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeleteResponse.kt index cf7d3b742..4604f242c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateDeleteResponse.kt @@ -162,6 +162,14 @@ private constructor( 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(): CertificateDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListPageResponse.kt index dafd89652..0366b1741 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListPageResponse.kt @@ -276,6 +276,14 @@ private constructor( 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(): CertificateListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListParams.kt index d81d05e88..ccbc9bfe6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListParams.kt @@ -328,6 +328,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListResponse.kt index 3a6dcb2ca..2ae56e63c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateListResponse.kt @@ -307,6 +307,14 @@ private constructor( 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(): CertificateListResponse = apply { if (validated) { return@apply @@ -479,6 +487,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateRetrieveParams.kt index 467927cc3..6b3aea914 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateRetrieveParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateRetrieveParams.kt @@ -302,6 +302,15 @@ private constructor( 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(): Include = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateUpdateParams.kt index e77f17499..9233c6ead 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/certificates/CertificateUpdateParams.kt @@ -346,6 +346,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/Group.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/Group.kt index 1f28507e9..5f5422d00 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/Group.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/Group.kt @@ -271,6 +271,14 @@ private constructor( 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(): Group = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupCreateParams.kt index 01667dfb3..3b9b41fdb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupCreateParams.kt @@ -355,6 +355,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupDeleteResponse.kt index 223501c99..93afb68f6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupDeleteResponse.kt @@ -196,6 +196,14 @@ private constructor( 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(): GroupDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListPageResponse.kt index ad0d18c06..ae556e625 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListPageResponse.kt @@ -251,6 +251,14 @@ private constructor( 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(): GroupListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListParams.kt index b39f07dff..4ac584867 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupListParams.kt @@ -319,6 +319,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateParams.kt index 15d80b70c..89b9cc424 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateParams.kt @@ -374,6 +374,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateResponse.kt index 05df311c0..7711fef7e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/GroupUpdateResponse.kt @@ -237,6 +237,14 @@ private constructor( 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(): GroupUpdateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateParams.kt index 07936ac22..7a7ba11b9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateParams.kt @@ -374,6 +374,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateResponse.kt index 5ead2920b..b0efd3080 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleCreateResponse.kt @@ -198,6 +198,14 @@ private constructor( 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(): RoleCreateResponse = apply { if (validated) { return@apply @@ -491,6 +499,15 @@ private constructor( 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(): Group = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleDeleteResponse.kt index 128301d61..5c9001a5b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleDeleteResponse.kt @@ -167,6 +167,14 @@ private constructor( 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(): RoleDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListPageResponse.kt index be269f45d..6cac445a5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListPageResponse.kt @@ -255,6 +255,14 @@ private constructor( 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(): RoleListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListParams.kt index febdba7cb..10b990602 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListParams.kt @@ -327,6 +327,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListResponse.kt index 87de26d82..aabc3da55 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/roles/RoleListResponse.kt @@ -559,6 +559,14 @@ private constructor( 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(): RoleListResponse = apply { if (validated) { return@apply @@ -664,6 +672,15 @@ private constructor( 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(): CreatedByUserObj = apply { if (validated) { return@apply @@ -764,6 +781,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/OrganizationGroupUser.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/OrganizationGroupUser.kt index 4c1029925..df7543043 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/OrganizationGroupUser.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/OrganizationGroupUser.kt @@ -202,6 +202,14 @@ private constructor( 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(): OrganizationGroupUser = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateParams.kt index 3695f7a9e..15fd6abd0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateParams.kt @@ -374,6 +374,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateResponse.kt index 4d2d6c61b..de4bc4a21 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserCreateResponse.kt @@ -196,6 +196,14 @@ private constructor( 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(): UserCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserDeleteResponse.kt index b6edac4d9..4d47508a1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserDeleteResponse.kt @@ -163,6 +163,14 @@ private constructor( 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(): UserDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListPageResponse.kt index ff4d1fed1..6dca007e8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListPageResponse.kt @@ -255,6 +255,14 @@ private constructor( 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(): UserListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListParams.kt index 6675ca176..4829ecb9a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/groups/users/UserListParams.kt @@ -333,6 +333,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/Invite.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/Invite.kt index df6608518..bf5923f77 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/Invite.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/Invite.kt @@ -443,6 +443,14 @@ private constructor( 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(): Invite = apply { if (validated) { return@apply @@ -639,6 +647,15 @@ private constructor( 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(): Project = apply { if (validated) { return@apply @@ -757,6 +774,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -902,6 +929,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1034,6 +1070,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteCreateParams.kt index 233c6c2be..aa78bf78b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteCreateParams.kt @@ -525,6 +525,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -666,6 +675,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -854,6 +872,15 @@ private constructor( 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(): Project = apply { if (validated) { return@apply @@ -972,6 +999,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteDeleteResponse.kt index 42bf52f0b..691e88ce5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteDeleteResponse.kt @@ -189,6 +189,14 @@ private constructor( 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(): InviteDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteListPageResponse.kt index 0b0ae39c7..762af682d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/invites/InviteListPageResponse.kt @@ -281,6 +281,14 @@ private constructor( 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(): InviteListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/Project.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/Project.kt index 0601b646d..2bee5db8d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/Project.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/Project.kt @@ -350,6 +350,14 @@ private constructor( 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(): Project = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectCreateParams.kt index b31b09680..4c75e2795 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectCreateParams.kt @@ -524,6 +524,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectListPageResponse.kt index b1dddc616..5d26f8d20 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectListPageResponse.kt @@ -268,6 +268,14 @@ private constructor( 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(): ProjectListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectUpdateParams.kt index c70c1668c..61e6f3f05 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ProjectUpdateParams.kt @@ -496,6 +496,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyDeleteResponse.kt index bb577842f..f5a22b9e9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyDeleteResponse.kt @@ -187,6 +187,14 @@ private constructor( 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(): ApiKeyDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyListPageResponse.kt index bae1d695b..9abbbc687 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ApiKeyListPageResponse.kt @@ -270,6 +270,14 @@ private constructor( 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(): ApiKeyListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ProjectApiKey.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ProjectApiKey.kt index 8be7f65ac..ad430525b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ProjectApiKey.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/apikeys/ProjectApiKey.kt @@ -347,6 +347,14 @@ private constructor( 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(): ProjectApiKey = apply { if (validated) { return@apply @@ -559,6 +567,15 @@ private constructor( 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(): Owner = apply { if (validated) { return@apply @@ -821,6 +838,16 @@ private constructor( 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(): ServiceAccount = apply { if (validated) { return@apply @@ -967,6 +994,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -1271,6 +1308,16 @@ private constructor( 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(): User = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivatePageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivatePageResponse.kt index e52aac909..59e1910f2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivatePageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivatePageResponse.kt @@ -185,6 +185,14 @@ private constructor( 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(): CertificateActivatePageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateParams.kt index 6934f83ee..9b0b6f577 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateParams.kt @@ -408,6 +408,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateResponse.kt index e0b7e03e1..e7761291b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateActivateResponse.kt @@ -307,6 +307,14 @@ private constructor( 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(): CertificateActivateResponse = apply { if (validated) { return@apply @@ -479,6 +487,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivatePageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivatePageResponse.kt index 8d40b4603..937df49dc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivatePageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivatePageResponse.kt @@ -185,6 +185,14 @@ private constructor( 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(): CertificateDeactivatePageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateParams.kt index 9d628537d..22484edea 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateParams.kt @@ -407,6 +407,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateResponse.kt index 1935f2435..37b912afc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateDeactivateResponse.kt @@ -308,6 +308,14 @@ private constructor( 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(): CertificateDeactivateResponse = apply { if (validated) { return@apply @@ -480,6 +488,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListPageResponse.kt index d0e836504..e501f84cb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListPageResponse.kt @@ -276,6 +276,14 @@ private constructor( 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(): CertificateListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListParams.kt index b50dbcea1..6e1422a64 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListParams.kt @@ -345,6 +345,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListResponse.kt index 0dd5347cf..ed4f1e593 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/certificates/CertificateListResponse.kt @@ -307,6 +307,14 @@ private constructor( 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(): CertificateListResponse = apply { if (validated) { return@apply @@ -479,6 +487,15 @@ private constructor( 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(): CertificateDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupCreateParams.kt index 122230a4e..ad942b84a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupCreateParams.kt @@ -440,6 +440,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupDeleteResponse.kt index bfae1911c..55f3fb9c9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupDeleteResponse.kt @@ -163,6 +163,14 @@ private constructor( 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(): GroupDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListPageResponse.kt index e9c52bc89..c48ec1faf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListPageResponse.kt @@ -253,6 +253,14 @@ private constructor( 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(): GroupListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListParams.kt index e85a33a87..4ef505c27 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/GroupListParams.kt @@ -327,6 +327,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/ProjectGroup.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/ProjectGroup.kt index 78fd2c09f..d1ac52444 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/ProjectGroup.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/ProjectGroup.kt @@ -298,6 +298,14 @@ private constructor( 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(): ProjectGroup = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateParams.kt index 326146afe..c303f0e5d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateParams.kt @@ -385,6 +385,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateResponse.kt index d5ecbdc16..1b39b3703 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleCreateResponse.kt @@ -198,6 +198,14 @@ private constructor( 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(): RoleCreateResponse = apply { if (validated) { return@apply @@ -491,6 +499,15 @@ private constructor( 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(): Group = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleDeleteResponse.kt index 1b93e5bdd..22cd6692f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleDeleteResponse.kt @@ -167,6 +167,14 @@ private constructor( 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(): RoleDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListPageResponse.kt index 46dfad409..b03e38470 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListPageResponse.kt @@ -255,6 +255,14 @@ private constructor( 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(): RoleListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListParams.kt index a7d8f2963..45873c8ee 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListParams.kt @@ -349,6 +349,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListResponse.kt index f8fb98ad3..76aa79864 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/groups/roles/RoleListResponse.kt @@ -559,6 +559,14 @@ private constructor( 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(): RoleListResponse = apply { if (validated) { return@apply @@ -664,6 +672,15 @@ private constructor( 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(): CreatedByUserObj = apply { if (validated) { return@apply @@ -764,6 +781,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/ProjectRateLimit.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/ProjectRateLimit.kt index 39c659b14..bb94290e8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/ProjectRateLimit.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/ProjectRateLimit.kt @@ -457,6 +457,14 @@ private constructor( 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(): ProjectRateLimit = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitListRateLimitsPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitListRateLimitsPageResponse.kt index e5503e989..826283c5b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitListRateLimitsPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitListRateLimitsPageResponse.kt @@ -274,6 +274,14 @@ private constructor( 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(): RateLimitListRateLimitsPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitUpdateRateLimitParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitUpdateRateLimitParams.kt index 0c047fa3b..28293716b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitUpdateRateLimitParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/ratelimits/RateLimitUpdateRateLimitParams.kt @@ -765,6 +765,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleCreateParams.kt index 755267a53..0e822d193 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleCreateParams.kt @@ -544,6 +544,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleDeleteResponse.kt index cb8370fa7..3e84ac52d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleDeleteResponse.kt @@ -196,6 +196,14 @@ private constructor( 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(): RoleDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListPageResponse.kt index 971c70203..ec64f0fe8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListPageResponse.kt @@ -253,6 +253,14 @@ private constructor( 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(): RoleListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListParams.kt index 5b9d8f17b..bedf9e02c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleListParams.kt @@ -327,6 +327,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleUpdateParams.kt index 954e38819..879a609b6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/roles/RoleUpdateParams.kt @@ -549,6 +549,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ProjectServiceAccount.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ProjectServiceAccount.kt index 871deb288..9f70e6ac5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ProjectServiceAccount.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ProjectServiceAccount.kt @@ -264,6 +264,14 @@ private constructor( 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(): ProjectServiceAccount = apply { if (validated) { return@apply @@ -392,6 +400,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateParams.kt index a54637ca6..193d76a08 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateParams.kt @@ -376,6 +376,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateResponse.kt index 4e8ca7b66..abd593d58 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountCreateResponse.kt @@ -284,6 +284,14 @@ private constructor( 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(): ServiceAccountCreateResponse = apply { if (validated) { return@apply @@ -571,6 +579,15 @@ private constructor( 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(): ApiKey = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountDeleteResponse.kt index 7c7198b05..62c43169d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountDeleteResponse.kt @@ -188,6 +188,14 @@ private constructor( 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(): ServiceAccountDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountListPageResponse.kt index 30783d2ef..397924312 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/serviceaccounts/ServiceAccountListPageResponse.kt @@ -272,6 +272,14 @@ private constructor( 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(): ServiceAccountListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/ProjectUser.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/ProjectUser.kt index 160142210..01def33c1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/ProjectUser.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/ProjectUser.kt @@ -299,6 +299,14 @@ private constructor( 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(): ProjectUser = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserCreateParams.kt index e753bfa69..fb9531778 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserCreateParams.kt @@ -509,6 +509,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserDeleteResponse.kt index 517cafc84..27b42c272 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserDeleteResponse.kt @@ -187,6 +187,14 @@ private constructor( 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(): UserDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserListPageResponse.kt index 0e5ee9909..11f329ffd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserListPageResponse.kt @@ -268,6 +268,14 @@ private constructor( 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(): UserListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserUpdateParams.kt index daa0151c0..8a7042bea 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/UserUpdateParams.kt @@ -373,6 +373,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateParams.kt index ff977cd02..43f3368dd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateParams.kt @@ -385,6 +385,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateResponse.kt index f1c6b1451..0be3ef292 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleCreateResponse.kt @@ -200,6 +200,14 @@ private constructor( 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(): RoleCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleDeleteResponse.kt index 2e6d906f4..1250dac58 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleDeleteResponse.kt @@ -167,6 +167,14 @@ private constructor( 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(): RoleDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListPageResponse.kt index 14c00a585..32c1d8c5b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListPageResponse.kt @@ -255,6 +255,14 @@ private constructor( 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(): RoleListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListParams.kt index 1cd29af26..ed56f72a2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListParams.kt @@ -349,6 +349,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListResponse.kt index 13a30650a..096b63fec 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/projects/users/roles/RoleListResponse.kt @@ -559,6 +559,14 @@ private constructor( 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(): RoleListResponse = apply { if (validated) { return@apply @@ -664,6 +672,15 @@ private constructor( 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(): CreatedByUserObj = apply { if (validated) { return@apply @@ -764,6 +781,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/Role.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/Role.kt index c3b6001fe..d03717dba 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/Role.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/Role.kt @@ -380,6 +380,14 @@ private constructor( 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(): Role = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleCreateParams.kt index 6bb2ce7f7..dc070b962 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleCreateParams.kt @@ -523,6 +523,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleDeleteResponse.kt index 5360eeb0a..b92dd295a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleDeleteResponse.kt @@ -196,6 +196,14 @@ private constructor( 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(): RoleDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListPageResponse.kt index 0c90ac8c0..8499fc26d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListPageResponse.kt @@ -252,6 +252,14 @@ private constructor( 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(): RoleListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListParams.kt index 1feb32fda..5fdb0fa62 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleListParams.kt @@ -310,6 +310,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleUpdateParams.kt index 6bab4882b..dae5bcc00 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/roles/RoleUpdateParams.kt @@ -527,6 +527,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesParams.kt index 12932b64b..a7e99598c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesParams.kt @@ -509,6 +509,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -646,6 +655,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesResponse.kt index 5335640f4..1aa7725dc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioSpeechesResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageAudioSpeechesResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsParams.kt index 9237bcaf7..a338e3c8b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsParams.kt @@ -510,6 +510,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -647,6 +656,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsResponse.kt index c2513c557..069f27748 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageAudioTranscriptionsResponse.kt @@ -251,6 +251,14 @@ private constructor( 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(): UsageAudioTranscriptionsResponse = apply { if (validated) { return@apply @@ -618,6 +626,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -783,6 +800,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -811,6 +858,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1923,6 +1980,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2417,6 +2484,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2887,6 +2964,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3440,6 +3527,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3917,6 +4014,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4387,6 +4494,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4683,6 +4800,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4957,6 +5084,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5037,6 +5174,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5055,7 +5193,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5103,6 +5244,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5141,6 +5291,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5170,6 +5330,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5179,6 +5340,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5265,6 +5427,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5299,12 +5486,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5319,6 +5517,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5344,7 +5543,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5491,6 +5691,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5552,6 +5762,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5562,6 +5773,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5569,7 +5781,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsParams.kt index e672252be..be717480f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsParams.kt @@ -435,6 +435,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -554,6 +563,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsResponse.kt index 61f3f7b76..c7256b358 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCodeInterpreterSessionsResponse.kt @@ -252,6 +252,14 @@ private constructor( 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(): UsageCodeInterpreterSessionsResponse = apply { if (validated) { return@apply @@ -619,6 +627,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -784,6 +801,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -812,6 +859,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1924,6 +1981,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2418,6 +2485,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2888,6 +2965,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3441,6 +3528,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3918,6 +4015,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4388,6 +4495,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4684,6 +4801,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4958,6 +5085,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5038,6 +5175,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5056,7 +5194,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5104,6 +5245,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5142,6 +5292,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5171,6 +5331,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5180,6 +5341,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5266,6 +5428,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5300,12 +5487,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5320,6 +5518,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5345,7 +5544,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5492,6 +5692,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5553,6 +5763,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5563,6 +5774,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5570,7 +5782,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsParams.kt index b9ad2fb9f..8b262f689 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsParams.kt @@ -536,6 +536,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -685,6 +694,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsResponse.kt index f7b054541..e376b595b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCompletionsResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageCompletionsResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsParams.kt index 744ade25d..58d8abf4f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsParams.kt @@ -440,6 +440,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -571,6 +580,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsResponse.kt index 185806862..54be7a20e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageCostsResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageCostsResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsParams.kt index bd7a575d1..a18f8810f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsParams.kt @@ -509,6 +509,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -646,6 +655,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsResponse.kt index db87d1d63..20b293ad4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageEmbeddingsResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageEmbeddingsResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesParams.kt index 6a154e60c..575a40f01 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesParams.kt @@ -565,6 +565,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -714,6 +723,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply @@ -857,6 +875,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply @@ -988,6 +1015,15 @@ private constructor( 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 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesResponse.kt index 312c3fae0..f9b1a23de 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageImagesResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageImagesResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsParams.kt index 7e90d33e1..eddd66967 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsParams.kt @@ -509,6 +509,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -646,6 +655,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsResponse.kt index eea4fbfd7..08efff6e6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageModerationsResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageModerationsResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresParams.kt index 73804ddb2..8d4ac6d7f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresParams.kt @@ -432,6 +432,15 @@ private constructor( 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(): BucketWidth = apply { if (validated) { return@apply @@ -551,6 +560,15 @@ private constructor( 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(): GroupBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresResponse.kt index c0aaf50b2..1adb3b3ff 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/usage/UsageVectorStoresResponse.kt @@ -248,6 +248,14 @@ private constructor( 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(): UsageVectorStoresResponse = apply { if (validated) { return@apply @@ -615,6 +623,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -780,6 +797,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = result.accept(new Result.Visitor>() { + * @Override + * public Optional visitOrganizationUsageCompletions(OrganizationUsageCompletionsResult organizationUsageCompletions) { + * return Optional.of(organizationUsageCompletions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { organizationUsageCompletions != null -> @@ -808,6 +855,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1920,6 +1977,16 @@ private constructor( 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(): OrganizationUsageCompletionsResult = apply { if (validated) { return@apply @@ -2414,6 +2481,16 @@ private constructor( 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(): OrganizationUsageEmbeddingsResult = apply { if (validated) { return@apply @@ -2884,6 +2961,16 @@ private constructor( 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(): OrganizationUsageModerationsResult = apply { if (validated) { return@apply @@ -3437,6 +3524,16 @@ private constructor( 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(): OrganizationUsageImagesResult = apply { if (validated) { return@apply @@ -3914,6 +4011,16 @@ private constructor( 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(): OrganizationUsageAudioSpeechesResult = apply { if (validated) { return@apply @@ -4384,6 +4491,16 @@ private constructor( 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(): OrganizationUsageAudioTranscriptionsResult = apply { if (validated) { return@apply @@ -4680,6 +4797,16 @@ private constructor( 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(): OrganizationUsageVectorStoresResult = apply { if (validated) { return@apply @@ -4954,6 +5081,16 @@ private constructor( 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(): OrganizationUsageCodeInterpreterSessionsResult = apply { if (validated) { return@apply @@ -5034,6 +5171,7 @@ private constructor( private val apiKeyId: JsonField, private val lineItem: JsonField, private val projectId: JsonField, + private val quantity: JsonField, private val additionalProperties: MutableMap, ) { @@ -5052,7 +5190,10 @@ private constructor( @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - ) : this(object_, amount, apiKeyId, lineItem, projectId, mutableMapOf()) + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + ) : this(object_, amount, apiKeyId, lineItem, projectId, quantity, mutableMapOf()) /** * Expected to always return the following: @@ -5100,6 +5241,15 @@ private constructor( */ fun projectId(): Optional = projectId.getOptional("project_id") + /** + * When `group_by=line_item`, this field provides the quantity of the grouped costs + * result. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + /** * Returns the raw JSON value of [amount]. * @@ -5138,6 +5288,16 @@ private constructor( @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -5167,6 +5327,7 @@ private constructor( private var apiKeyId: JsonField = JsonMissing.of() private var lineItem: JsonField = JsonMissing.of() private var projectId: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5176,6 +5337,7 @@ private constructor( apiKeyId = organizationCostsResult.apiKeyId lineItem = organizationCostsResult.lineItem projectId = organizationCostsResult.projectId + quantity = organizationCostsResult.quantity additionalProperties = organizationCostsResult.additionalProperties.toMutableMap() } @@ -5262,6 +5424,31 @@ private constructor( this.projectId = projectId } + /** + * When `group_by=line_item`, this field provides the quantity of the grouped + * costs result. + */ + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** + * Alias for [Builder.quantity]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5296,12 +5483,23 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, 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(): OrganizationCostsResult = apply { if (validated) { return@apply @@ -5316,6 +5514,7 @@ private constructor( apiKeyId() lineItem() projectId() + quantity() validated = true } @@ -5341,7 +5540,8 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (apiKeyId.asKnown().isPresent) 1 else 0) + (if (lineItem.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) /** The monetary value in its associated currency. */ class Amount @@ -5488,6 +5688,16 @@ private constructor( 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(): Amount = apply { if (validated) { return@apply @@ -5549,6 +5759,7 @@ private constructor( apiKeyId == other.apiKeyId && lineItem == other.lineItem && projectId == other.projectId && + quantity == other.quantity && additionalProperties == other.additionalProperties } @@ -5559,6 +5770,7 @@ private constructor( apiKeyId, lineItem, projectId, + quantity, additionalProperties, ) } @@ -5566,7 +5778,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, additionalProperties=$additionalProperties}" + "OrganizationCostsResult{object_=$object_, amount=$amount, apiKeyId=$apiKeyId, lineItem=$lineItem, projectId=$projectId, quantity=$quantity, additionalProperties=$additionalProperties}" } } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/OrganizationUser.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/OrganizationUser.kt index 57c77a5cf..f93cddd0b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/OrganizationUser.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/OrganizationUser.kt @@ -724,6 +724,14 @@ private constructor( 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(): OrganizationUser = apply { if (validated) { return@apply @@ -942,6 +950,15 @@ private constructor( 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(): Projects = apply { if (validated) { return@apply @@ -1138,6 +1155,16 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -1565,6 +1592,15 @@ private constructor( 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(): User = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserDeleteResponse.kt index cc5c73737..a9ee7965c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserDeleteResponse.kt @@ -187,6 +187,14 @@ private constructor( 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(): UserDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserListPageResponse.kt index 7d57674cb..8cfa6993a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserListPageResponse.kt @@ -270,6 +270,14 @@ private constructor( 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(): UserListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserUpdateParams.kt index e1158617b..cf81ba4ce 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/UserUpdateParams.kt @@ -581,6 +581,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateParams.kt index aaff4a596..fb869b5b0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateParams.kt @@ -374,6 +374,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateResponse.kt index 30e27da98..f41a17181 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleCreateResponse.kt @@ -200,6 +200,14 @@ private constructor( 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(): RoleCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleDeleteResponse.kt index f9a12fd30..685607c90 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleDeleteResponse.kt @@ -167,6 +167,14 @@ private constructor( 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(): RoleDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListPageResponse.kt index c02544f71..df48519bc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListPageResponse.kt @@ -255,6 +255,14 @@ private constructor( 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(): RoleListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListParams.kt index 086f850d9..863d095c5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListParams.kt @@ -327,6 +327,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListResponse.kt index d7d00cd95..10c626e05 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/admin/organization/users/roles/RoleListResponse.kt @@ -559,6 +559,14 @@ private constructor( 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(): RoleListResponse = apply { if (validated) { return@apply @@ -664,6 +672,15 @@ private constructor( 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(): CreatedByUserObj = apply { if (validated) { return@apply @@ -764,6 +781,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/AudioModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/AudioModel.kt index a666e028d..9426089e3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/AudioModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/AudioModel.kt @@ -110,6 +110,14 @@ class AudioModel @JsonCreator private constructor(private val value: JsonField = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = voice.accept(new Voice.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -997,6 +1035,15 @@ private constructor( 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(): Voice = apply { if (validated) { return@apply @@ -1296,6 +1343,16 @@ private constructor( 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(): UnionMember1 = apply { if (validated) { return@apply @@ -1451,6 +1508,16 @@ private constructor( 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(): Id = apply { if (validated) { return@apply @@ -1612,6 +1679,15 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply @@ -1744,6 +1820,15 @@ private constructor( 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(): StreamFormat = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechModel.kt index fb2a23044..23e963f56 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/speech/SpeechModel.kt @@ -104,6 +104,14 @@ class SpeechModel @JsonCreator private constructor(private val value: JsonField< 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(): SpeechModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/Transcription.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/Transcription.kt index c88c829f6..0a5c60f00 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/Transcription.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/Transcription.kt @@ -247,6 +247,14 @@ private constructor( 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(): Transcription = apply { if (validated) { return@apply @@ -459,6 +467,15 @@ private constructor( 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(): Logprob = apply { if (validated) { return@apply @@ -540,6 +557,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = usage.accept(new Usage.Visitor>() { + * @Override + * public Optional visitTokens(Tokens tokens) { + * return Optional.of(tokens.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { tokens != null -> visitor.visitTokens(tokens) @@ -549,6 +595,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply @@ -976,6 +1031,16 @@ private constructor( 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(): Tokens = apply { if (validated) { return@apply @@ -1170,6 +1235,16 @@ private constructor( 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(): InputTokenDetails = apply { if (validated) { return@apply @@ -1406,6 +1481,16 @@ private constructor( 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(): Duration = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt index 2efe394d5..37d96b18c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateParams.kt @@ -1394,6 +1394,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1495,6 +1504,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chunkingStrategy.accept(new ChunkingStrategy.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1504,6 +1542,15 @@ private constructor( 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(): ChunkingStrategy = apply { if (validated) { return@apply @@ -1846,6 +1893,16 @@ private constructor( 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(): VadConfig = apply { if (validated) { return@apply @@ -1953,6 +2010,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -2114,6 +2181,15 @@ private constructor( 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(): TimestampGranularity = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateResponse.kt index e68d73158..a935a9a7d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionCreateResponse.kt @@ -67,6 +67,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = transcriptionCreateResponse.accept(new TranscriptionCreateResponse.Visitor>() { + * @Override + * public Optional visitTranscription(Transcription transcription) { + * return Optional.of(transcription.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { transcription != null -> visitor.visitTranscription(transcription) @@ -77,6 +106,14 @@ private constructor( 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(): TranscriptionCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarized.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarized.kt index 1f2dcbc68..f8a368ef3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarized.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarized.kt @@ -314,6 +314,14 @@ private constructor( 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(): TranscriptionDiarized = apply { if (validated) { return@apply @@ -380,6 +388,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = usage.accept(new Usage.Visitor>() { + * @Override + * public Optional visitTokens(Tokens tokens) { + * return Optional.of(tokens.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { tokens != null -> visitor.visitTokens(tokens) @@ -389,6 +426,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply @@ -816,6 +862,16 @@ private constructor( 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(): Tokens = apply { if (validated) { return@apply @@ -1010,6 +1066,16 @@ private constructor( 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(): InputTokenDetails = apply { if (validated) { return@apply @@ -1246,6 +1312,16 @@ private constructor( 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(): Duration = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarizedSegment.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarizedSegment.kt index 28eb420d9..f76d9f829 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarizedSegment.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionDiarizedSegment.kt @@ -301,6 +301,14 @@ private constructor( 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(): TranscriptionDiarizedSegment = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionInclude.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionInclude.kt index 351d8191b..3d33c1321 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionInclude.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionInclude.kt @@ -90,6 +90,14 @@ class TranscriptionInclude @JsonCreator private constructor(private val value: J 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(): TranscriptionInclude = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionSegment.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionSegment.kt index 146972834..6a6f2c45b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionSegment.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionSegment.kt @@ -490,6 +490,14 @@ private constructor( 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(): TranscriptionSegment = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionStreamEvent.kt index 4a34a8d21..7a7ebf584 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionStreamEvent.kt @@ -96,6 +96,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = transcriptionStreamEvent.accept(new TranscriptionStreamEvent.Visitor>() { + * @Override + * public Optional visitTranscriptTextSegment(TranscriptionTextSegmentEvent transcriptTextSegment) { + * return Optional.of(transcriptTextSegment.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { transcriptTextSegment != null -> @@ -107,6 +136,14 @@ private constructor( 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(): TranscriptionStreamEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDeltaEvent.kt index 7c367169a..5273f10c8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDeltaEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDeltaEvent.kt @@ -262,6 +262,14 @@ private constructor( 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(): TranscriptionTextDeltaEvent = apply { if (validated) { return@apply @@ -478,6 +486,15 @@ private constructor( 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(): Logprob = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDoneEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDoneEvent.kt index 795b8190b..6af55660d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDoneEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextDoneEvent.kt @@ -257,6 +257,14 @@ private constructor( 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(): TranscriptionTextDoneEvent = apply { if (validated) { return@apply @@ -473,6 +481,15 @@ private constructor( 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(): Logprob = apply { if (validated) { return@apply @@ -799,6 +816,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply @@ -986,6 +1012,16 @@ private constructor( 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(): InputTokenDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextSegmentEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextSegmentEvent.kt index b1436e530..e723a65c3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextSegmentEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionTextSegmentEvent.kt @@ -301,6 +301,14 @@ private constructor( 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(): TranscriptionTextSegmentEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionVerbose.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionVerbose.kt index 86478afbc..46980eaf9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionVerbose.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionVerbose.kt @@ -330,6 +330,14 @@ private constructor( 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(): TranscriptionVerbose = apply { if (validated) { return@apply @@ -511,6 +519,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionWord.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionWord.kt index 4f0f84cd5..71afaddbe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionWord.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/transcriptions/TranscriptionWord.kt @@ -196,6 +196,14 @@ private constructor( 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(): TranscriptionWord = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/Translation.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/Translation.kt index 246c67536..dbdd26240 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/Translation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/Translation.kt @@ -124,6 +124,14 @@ private constructor( 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(): Translation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt index 3f806de73..a136e1cd0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateParams.kt @@ -730,6 +730,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -888,6 +897,15 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateResponse.kt index 2cad0ebd7..f4f8e002e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationCreateResponse.kt @@ -41,6 +41,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = translationCreateResponse.accept(new TranslationCreateResponse.Visitor>() { + * @Override + * public Optional visitTranslation(Translation translation) { + * return Optional.of(translation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { translation != null -> visitor.visitTranslation(translation) @@ -50,6 +79,14 @@ private constructor( 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(): TranslationCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationVerbose.kt b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationVerbose.kt index 431a97eb2..e6f41007c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationVerbose.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/audio/translations/TranslationVerbose.kt @@ -251,6 +251,14 @@ private constructor( 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(): TranslationVerbose = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/Batch.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/Batch.kt index 6b855904c..3d2c4c67f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/Batch.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/Batch.kt @@ -900,6 +900,14 @@ private constructor( 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(): Batch = apply { if (validated) { return@apply @@ -1096,6 +1104,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -1281,6 +1298,15 @@ private constructor( 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(): Errors = apply { if (validated) { return@apply @@ -1395,6 +1421,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt index eabb949ec..0806260f7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchCreateParams.kt @@ -753,6 +753,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -907,6 +916,15 @@ private constructor( 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(): CompletionWindow = apply { if (validated) { return@apply @@ -1075,6 +1093,15 @@ private constructor( 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(): Endpoint = apply { if (validated) { return@apply @@ -1179,6 +1206,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1375,6 +1411,15 @@ private constructor( 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(): OutputExpiresAfter = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchError.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchError.kt index 17b864ac5..db33d1f52 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchError.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchError.kt @@ -217,6 +217,14 @@ private constructor( 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(): BatchError = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchListPageResponse.kt index aab947bfe..788c08cab 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchListPageResponse.kt @@ -262,6 +262,14 @@ private constructor( 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(): BatchListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchRequestCounts.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchRequestCounts.kt index 697fabbad..790860097 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchRequestCounts.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchRequestCounts.kt @@ -197,6 +197,14 @@ private constructor( 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(): BatchRequestCounts = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchUsage.kt b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchUsage.kt index 28176d096..d8f4bec54 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchUsage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/batches/BatchUsage.kt @@ -305,6 +305,14 @@ private constructor( 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(): BatchUsage = apply { if (validated) { return@apply @@ -467,6 +475,15 @@ private constructor( 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(): InputTokensDetails = apply { if (validated) { return@apply @@ -636,6 +653,15 @@ private constructor( 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(): OutputTokensDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/Assistant.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/Assistant.kt index becdbe0bb..3c4516f61 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/Assistant.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/Assistant.kt @@ -762,6 +762,14 @@ private constructor( 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(): Assistant = apply { if (validated) { return@apply @@ -882,6 +890,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1067,6 +1084,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -1225,6 +1251,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -1402,6 +1438,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt index d7410edb8..0613798c1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantCreateParams.kt @@ -1498,6 +1498,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1654,6 +1663,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1839,6 +1857,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -1997,6 +2024,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -2235,6 +2272,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply @@ -2514,6 +2561,16 @@ private constructor( 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(): VectorStore = apply { if (validated) { return@apply @@ -2580,6 +2637,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chunkingStrategy.accept(new ChunkingStrategy.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -2589,6 +2677,16 @@ private constructor( 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(): ChunkingStrategy = apply { if (validated) { return@apply @@ -2906,6 +3004,16 @@ private constructor( 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(): Static = apply { if (validated) { return@apply @@ -3136,6 +3244,16 @@ private constructor( 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(): InnerStatic = apply { if (validated) { return@apply @@ -3282,6 +3400,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleted.kt index f5fc11ebd..538c1cee7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantDeleted.kt @@ -187,6 +187,14 @@ private constructor( 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(): AssistantDeleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListPageResponse.kt index dac2fc72b..95fe99372 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListPageResponse.kt @@ -265,6 +265,14 @@ private constructor( 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(): AssistantListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListParams.kt index 1a1acfc2c..3a388753b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantListParams.kt @@ -352,6 +352,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantStreamEvent.kt index f8d6765b3..94747f623 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantStreamEvent.kt @@ -447,6 +447,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = assistantStreamEvent.accept(new AssistantStreamEvent.Visitor>() { + * @Override + * public Optional visitThreadCreated(ThreadCreated threadCreated) { + * return Optional.of(threadCreated.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { threadCreated != null -> visitor.visitThreadCreated(threadCreated) @@ -485,6 +514,14 @@ private constructor( 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(): AssistantStreamEvent = apply { if (validated) { return@apply @@ -1552,6 +1589,15 @@ private constructor( 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(): ThreadCreated = apply { if (validated) { return@apply @@ -1763,6 +1809,15 @@ private constructor( 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(): ThreadRunCreated = apply { if (validated) { return@apply @@ -1969,6 +2024,15 @@ private constructor( 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(): ThreadRunQueued = apply { if (validated) { return@apply @@ -2175,6 +2239,15 @@ private constructor( 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(): ThreadRunInProgress = apply { if (validated) { return@apply @@ -2381,6 +2454,15 @@ private constructor( 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(): ThreadRunRequiresAction = apply { if (validated) { return@apply @@ -2586,6 +2668,15 @@ private constructor( 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(): ThreadRunCompleted = apply { if (validated) { return@apply @@ -2792,6 +2883,15 @@ private constructor( 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(): ThreadRunIncomplete = apply { if (validated) { return@apply @@ -2995,6 +3095,15 @@ private constructor( 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(): ThreadRunFailed = apply { if (validated) { return@apply @@ -3201,6 +3310,15 @@ private constructor( 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(): ThreadRunCancelling = apply { if (validated) { return@apply @@ -3406,6 +3524,15 @@ private constructor( 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(): ThreadRunCancelled = apply { if (validated) { return@apply @@ -3609,6 +3736,15 @@ private constructor( 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(): ThreadRunExpired = apply { if (validated) { return@apply @@ -3811,6 +3947,15 @@ private constructor( 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(): ThreadRunStepCreated = apply { if (validated) { return@apply @@ -4014,6 +4159,15 @@ private constructor( 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(): ThreadRunStepInProgress = apply { if (validated) { return@apply @@ -4221,6 +4375,15 @@ private constructor( 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(): ThreadRunStepDelta = apply { if (validated) { return@apply @@ -4424,6 +4587,15 @@ private constructor( 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(): ThreadRunStepCompleted = apply { if (validated) { return@apply @@ -4626,6 +4798,15 @@ private constructor( 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(): ThreadRunStepFailed = apply { if (validated) { return@apply @@ -4829,6 +5010,15 @@ private constructor( 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(): ThreadRunStepCancelled = apply { if (validated) { return@apply @@ -5031,6 +5221,15 @@ private constructor( 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(): ThreadRunStepExpired = apply { if (validated) { return@apply @@ -5237,6 +5436,15 @@ private constructor( 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(): ThreadMessageCreated = apply { if (validated) { return@apply @@ -5443,6 +5651,15 @@ private constructor( 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(): ThreadMessageInProgress = apply { if (validated) { return@apply @@ -5647,6 +5864,15 @@ private constructor( 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(): ThreadMessageDelta = apply { if (validated) { return@apply @@ -5853,6 +6079,15 @@ private constructor( 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(): ThreadMessageCompleted = apply { if (validated) { return@apply @@ -6059,6 +6294,15 @@ private constructor( 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(): ThreadMessageIncomplete = apply { if (validated) { return@apply @@ -6254,6 +6498,15 @@ private constructor( 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(): ErrorEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantTool.kt index a9429e4bc..4f7c98368 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantTool.kt @@ -48,6 +48,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = assistantTool.accept(new AssistantTool.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -58,6 +87,14 @@ private constructor( 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(): AssistantTool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt index 79536e6dd..93e6ecff9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/AssistantUpdateParams.kt @@ -1478,6 +1478,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1634,6 +1643,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2008,6 +2026,15 @@ private constructor( 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(): Model = apply { if (validated) { return@apply @@ -2190,6 +2217,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -2349,6 +2385,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -2526,6 +2572,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/CodeInterpreterTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/CodeInterpreterTool.kt index 49efcafd1..46765cc4d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/CodeInterpreterTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/CodeInterpreterTool.kt @@ -112,6 +112,14 @@ private constructor( 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(): CodeInterpreterTool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FileSearchTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FileSearchTool.kt index 5326e56e7..56275abfc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FileSearchTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FileSearchTool.kt @@ -152,6 +152,14 @@ private constructor( 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(): FileSearchTool = apply { if (validated) { return@apply @@ -358,6 +366,15 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply @@ -562,6 +579,16 @@ private constructor( 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(): RankingOptions = apply { if (validated) { return@apply @@ -687,6 +714,16 @@ private constructor( 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(): Ranker = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FunctionTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FunctionTool.kt index 9b80bac25..759d28d9c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FunctionTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/FunctionTool.kt @@ -166,6 +166,14 @@ private constructor( 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(): FunctionTool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/MessageStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/MessageStreamEvent.kt index 29e2e73f5..b123466c2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/MessageStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/MessageStreamEvent.kt @@ -126,6 +126,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = messageStreamEvent.accept(new MessageStreamEvent.Visitor>() { + * @Override + * public Optional visitThreadMessageCreated(ThreadMessageCreated threadMessageCreated) { + * return Optional.of(threadMessageCreated.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { threadMessageCreated != null -> visitor.visitThreadMessageCreated(threadMessageCreated) @@ -141,6 +170,14 @@ private constructor( 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(): MessageStreamEvent = apply { if (validated) { return@apply @@ -566,6 +603,15 @@ private constructor( 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(): ThreadMessageCreated = apply { if (validated) { return@apply @@ -772,6 +818,15 @@ private constructor( 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(): ThreadMessageInProgress = apply { if (validated) { return@apply @@ -976,6 +1031,15 @@ private constructor( 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(): ThreadMessageDelta = apply { if (validated) { return@apply @@ -1182,6 +1246,15 @@ private constructor( 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(): ThreadMessageCompleted = apply { if (validated) { return@apply @@ -1388,6 +1461,15 @@ private constructor( 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(): ThreadMessageIncomplete = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStepStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStepStreamEvent.kt index f8bed71d6..3ea6ed58e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStepStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStepStreamEvent.kt @@ -168,6 +168,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = runStepStreamEvent.accept(new RunStepStreamEvent.Visitor>() { + * @Override + * public Optional visitThreadRunStepCreated(ThreadRunStepCreated threadRunStepCreated) { + * return Optional.of(threadRunStepCreated.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { threadRunStepCreated != null -> visitor.visitThreadRunStepCreated(threadRunStepCreated) @@ -185,6 +214,14 @@ private constructor( 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(): RunStepStreamEvent = apply { if (validated) { return@apply @@ -678,6 +715,15 @@ private constructor( 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(): ThreadRunStepCreated = apply { if (validated) { return@apply @@ -881,6 +927,15 @@ private constructor( 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(): ThreadRunStepInProgress = apply { if (validated) { return@apply @@ -1088,6 +1143,15 @@ private constructor( 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(): ThreadRunStepDelta = apply { if (validated) { return@apply @@ -1291,6 +1355,15 @@ private constructor( 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(): ThreadRunStepCompleted = apply { if (validated) { return@apply @@ -1493,6 +1566,15 @@ private constructor( 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(): ThreadRunStepFailed = apply { if (validated) { return@apply @@ -1696,6 +1778,15 @@ private constructor( 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(): ThreadRunStepCancelled = apply { if (validated) { return@apply @@ -1898,6 +1989,15 @@ private constructor( 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(): ThreadRunStepExpired = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStreamEvent.kt index 0bef42b96..01e48fb91 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/RunStreamEvent.kt @@ -184,6 +184,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = runStreamEvent.accept(new RunStreamEvent.Visitor>() { + * @Override + * public Optional visitThreadRunCreated(ThreadRunCreated threadRunCreated) { + * return Optional.of(threadRunCreated.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { threadRunCreated != null -> visitor.visitThreadRunCreated(threadRunCreated) @@ -202,6 +231,14 @@ private constructor( 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(): RunStreamEvent = apply { if (validated) { return@apply @@ -763,6 +800,15 @@ private constructor( 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(): ThreadRunCreated = apply { if (validated) { return@apply @@ -969,6 +1015,15 @@ private constructor( 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(): ThreadRunQueued = apply { if (validated) { return@apply @@ -1175,6 +1230,15 @@ private constructor( 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(): ThreadRunInProgress = apply { if (validated) { return@apply @@ -1381,6 +1445,15 @@ private constructor( 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(): ThreadRunRequiresAction = apply { if (validated) { return@apply @@ -1586,6 +1659,15 @@ private constructor( 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(): ThreadRunCompleted = apply { if (validated) { return@apply @@ -1792,6 +1874,15 @@ private constructor( 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(): ThreadRunIncomplete = apply { if (validated) { return@apply @@ -1995,6 +2086,15 @@ private constructor( 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(): ThreadRunFailed = apply { if (validated) { return@apply @@ -2201,6 +2301,15 @@ private constructor( 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(): ThreadRunCancelling = apply { if (validated) { return@apply @@ -2406,6 +2515,15 @@ private constructor( 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(): ThreadRunCancelled = apply { if (validated) { return@apply @@ -2609,6 +2727,15 @@ private constructor( 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(): ThreadRunExpired = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/ThreadStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/ThreadStreamEvent.kt index a412c8182..323d245e0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/ThreadStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/assistants/ThreadStreamEvent.kt @@ -202,6 +202,14 @@ private constructor( 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(): ThreadStreamEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/ChatKitWorkflow.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/ChatKitWorkflow.kt index 972434f9e..9ab97a831 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/ChatKitWorkflow.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/ChatKitWorkflow.kt @@ -256,6 +256,14 @@ private constructor( 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(): ChatKitWorkflow = apply { if (validated) { return@apply @@ -350,6 +358,15 @@ private constructor( 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(): StateVariables = apply { if (validated) { return@apply @@ -505,6 +522,15 @@ private constructor( 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(): Tracing = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/sessions/SessionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/sessions/SessionCreateParams.kt index f5880fdae..12e66290f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/sessions/SessionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/sessions/SessionCreateParams.kt @@ -678,6 +678,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitAttachment.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitAttachment.kt index 7ea32ab81..96f21daaf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitAttachment.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitAttachment.kt @@ -272,6 +272,14 @@ private constructor( 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(): ChatKitAttachment = apply { if (validated) { return@apply @@ -394,6 +402,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitResponseOutputText.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitResponseOutputText.kt index 0a822a092..177d5de96 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitResponseOutputText.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitResponseOutputText.kt @@ -257,6 +257,14 @@ private constructor( 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(): ChatKitResponseOutputText = apply { if (validated) { return@apply @@ -319,6 +327,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = annotation.accept(new Annotation.Visitor>() { + * @Override + * public Optional visitFile(File file) { + * return Optional.of(file.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { file != null -> visitor.visitFile(file) @@ -328,6 +365,15 @@ private constructor( 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(): Annotation = apply { if (validated) { return@apply @@ -616,6 +662,16 @@ private constructor( 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(): File = apply { if (validated) { return@apply @@ -807,6 +863,16 @@ private constructor( 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 @@ -1031,6 +1097,16 @@ private constructor( 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(): Url = apply { if (validated) { return@apply @@ -1213,6 +1289,16 @@ private constructor( 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 diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThread.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThread.kt index e5e685039..d17446d42 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThread.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThread.kt @@ -349,6 +349,14 @@ private constructor( 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(): ChatKitThread = apply { if (validated) { return@apply @@ -426,6 +434,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = status.accept(new Status.Visitor>() { + * @Override + * public Optional visitActive(JsonValue active) { + * return Optional.of(active.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { active != null -> visitor.visitActive(active) @@ -436,6 +473,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -759,6 +805,16 @@ private constructor( 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(): Locked = apply { if (validated) { return@apply @@ -970,6 +1026,16 @@ private constructor( 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(): Closed = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadAssistantMessageItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadAssistantMessageItem.kt index c04443860..22725278a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadAssistantMessageItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadAssistantMessageItem.kt @@ -319,6 +319,14 @@ private constructor( 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(): ChatKitThreadAssistantMessageItem = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadItemList.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadItemList.kt index 54ff0c872..7f022f0d2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadItemList.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadItemList.kt @@ -324,6 +324,14 @@ private constructor( 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(): ChatKitThreadItemList = apply { if (validated) { return@apply @@ -432,6 +440,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = data.accept(new Data.Visitor>() { + * @Override + * public Optional visitChatKitUserMessage(ChatKitThreadUserMessageItem chatkitUserMessage) { + * return Optional.of(chatkitUserMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatkitUserMessage != null -> visitor.visitChatKitUserMessage(chatkitUserMessage) @@ -447,6 +484,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply @@ -1174,6 +1220,16 @@ private constructor( 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(): ChatKitClientToolCall = apply { if (validated) { return@apply @@ -1321,6 +1377,16 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -1791,6 +1857,16 @@ private constructor( 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(): ChatKitTask = apply { if (validated) { return@apply @@ -1934,6 +2010,16 @@ private constructor( 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(): TaskType = apply { if (validated) { return@apply @@ -2323,6 +2409,16 @@ private constructor( 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(): ChatKitTaskGroup = apply { if (validated) { return@apply @@ -2575,6 +2671,16 @@ private constructor( 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(): Task = apply { if (validated) { return@apply @@ -2701,6 +2807,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadUserMessageItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadUserMessageItem.kt index c761a8ae6..19c9b7d78 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadUserMessageItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitThreadUserMessageItem.kt @@ -462,6 +462,14 @@ private constructor( 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(): ChatKitThreadUserMessageItem = apply { if (validated) { return@apply @@ -538,6 +546,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitInputText(InputText inputText) { + * return Optional.of(inputText.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { inputText != null -> visitor.visitInputText(inputText) @@ -547,6 +584,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -839,6 +885,16 @@ private constructor( 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(): InputText = apply { if (validated) { return@apply @@ -1044,6 +1100,16 @@ private constructor( 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(): QuotedText = apply { if (validated) { return@apply @@ -1263,6 +1329,15 @@ private constructor( 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(): InferenceOptions = apply { if (validated) { return@apply @@ -1410,6 +1485,16 @@ private constructor( 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(): ToolChoice = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitWidgetItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitWidgetItem.kt index 4c5fff24d..3e3290b75 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitWidgetItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatKitWidgetItem.kt @@ -294,6 +294,14 @@ private constructor( 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(): ChatKitWidgetItem = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSession.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSession.kt index 5617c3253..9509651a1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSession.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSession.kt @@ -482,6 +482,14 @@ private constructor( 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(): ChatSession = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionAutomaticThreadTitling.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionAutomaticThreadTitling.kt index f738d438b..f64eb3bfe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionAutomaticThreadTitling.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionAutomaticThreadTitling.kt @@ -134,6 +134,14 @@ private constructor( 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(): ChatSessionAutomaticThreadTitling = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfiguration.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfiguration.kt index c3237097e..763c38765 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfiguration.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfiguration.kt @@ -222,6 +222,14 @@ private constructor( 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(): ChatSessionChatKitConfiguration = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfigurationParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfigurationParam.kt index d0106f3d6..f6d97f1ec 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfigurationParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionChatKitConfigurationParam.kt @@ -214,6 +214,14 @@ private constructor( 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(): ChatSessionChatKitConfigurationParam = apply { if (validated) { return@apply @@ -349,6 +357,15 @@ private constructor( 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(): AutomaticThreadTitling = apply { if (validated) { return@apply @@ -565,6 +582,15 @@ private constructor( 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(): FileUpload = apply { if (validated) { return@apply @@ -762,6 +788,15 @@ private constructor( 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(): History = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionExpiresAfterParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionExpiresAfterParam.kt index 38206ebba..85667dba2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionExpiresAfterParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionExpiresAfterParam.kt @@ -163,6 +163,14 @@ private constructor( 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(): ChatSessionExpiresAfterParam = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionFileUpload.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionFileUpload.kt index 4b5996b59..0e48c1c99 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionFileUpload.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionFileUpload.kt @@ -222,6 +222,14 @@ private constructor( 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(): ChatSessionFileUpload = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionHistory.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionHistory.kt index 56eae92ef..5da3dcf69 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionHistory.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionHistory.kt @@ -187,6 +187,14 @@ private constructor( 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(): ChatSessionHistory = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimits.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimits.kt index dec64882f..0c2d3afea 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimits.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimits.kt @@ -141,6 +141,14 @@ private constructor( 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(): ChatSessionRateLimits = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimitsParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimitsParam.kt index d399be01a..66566d87e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimitsParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionRateLimitsParam.kt @@ -126,6 +126,14 @@ private constructor( 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(): ChatSessionRateLimitsParam = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionStatus.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionStatus.kt index 933752012..2cd206074 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionStatus.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionStatus.kt @@ -102,6 +102,14 @@ class ChatSessionStatus @JsonCreator private constructor(private val value: Json 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(): ChatSessionStatus = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionWorkflowParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionWorkflowParam.kt index 3eb2472be..e3bee01a3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionWorkflowParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ChatSessionWorkflowParam.kt @@ -243,6 +243,14 @@ private constructor( 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(): ChatSessionWorkflowParam = apply { if (validated) { return@apply @@ -337,6 +345,15 @@ private constructor( 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(): StateVariables = apply { if (validated) { return@apply @@ -480,6 +497,15 @@ private constructor( 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(): Tracing = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadDeleteResponse.kt index 75c5e3de6..055094102 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadDeleteResponse.kt @@ -196,6 +196,14 @@ private constructor( 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(): ThreadDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListItemsParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListItemsParams.kt index ebbeef984..99145fd74 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListItemsParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListItemsParams.kt @@ -337,6 +337,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListPageResponse.kt index 85ecab1d4..d6a827179 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListPageResponse.kt @@ -289,6 +289,14 @@ private constructor( 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(): ThreadListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListParams.kt index d4f277f59..481ae56f3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/chatkit/threads/ThreadListParams.kt @@ -336,6 +336,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantResponseFormatOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantResponseFormatOption.kt index d89496131..9e9f99d7b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantResponseFormatOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantResponseFormatOption.kt @@ -105,6 +105,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = assistantResponseFormatOption.accept(new AssistantResponseFormatOption.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -118,6 +147,14 @@ private constructor( 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(): AssistantResponseFormatOption = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoice.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoice.kt index 7869a7635..203260a72 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoice.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoice.kt @@ -169,6 +169,14 @@ private constructor( 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(): AssistantToolChoice = apply { if (validated) { return@apply @@ -291,6 +299,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceFunction.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceFunction.kt index e041a6258..691226534 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceFunction.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceFunction.kt @@ -130,6 +130,14 @@ private constructor( 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(): AssistantToolChoiceFunction = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceOption.kt index 73b986113..e1ec817dc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/AssistantToolChoiceOption.kt @@ -66,6 +66,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = assistantToolChoiceOption.accept(new AssistantToolChoiceOption.Visitor>() { + * @Override + * public Optional visitAuto(Auto auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -75,6 +104,14 @@ private constructor( 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(): AssistantToolChoiceOption = apply { if (validated) { return@apply @@ -337,6 +374,15 @@ private constructor( 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(): Auto = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/Thread.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/Thread.kt index 60fc6d733..e0ed5140e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/Thread.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/Thread.kt @@ -304,6 +304,14 @@ private constructor( 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(): Thread = apply { if (validated) { return@apply @@ -408,6 +416,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -593,6 +610,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -751,6 +777,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -928,6 +964,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt index 0202733b9..8d188c876 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateAndRunParams.kt @@ -1926,6 +1926,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -2098,6 +2107,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2368,6 +2386,15 @@ private constructor( 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(): Thread = apply { if (validated) { return@apply @@ -2687,6 +2714,16 @@ private constructor( 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(): Message = apply { if (validated) { return@apply @@ -2758,6 +2795,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -2768,6 +2835,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -3036,6 +3113,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -3240,6 +3327,16 @@ private constructor( 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(): Attachment = apply { if (validated) { return@apply @@ -3294,6 +3391,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tool.accept(new Tool.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -3303,6 +3431,16 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply @@ -3553,6 +3691,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -3688,6 +3836,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -3878,6 +4036,16 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -4039,6 +4207,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -4278,6 +4456,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply @@ -4569,6 +4757,16 @@ private constructor( 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(): VectorStore = apply { if (validated) { return@apply @@ -4635,6 +4833,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chunkingStrategy.accept(new ChunkingStrategy.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -4644,6 +4873,16 @@ private constructor( 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(): ChunkingStrategy = apply { if (validated) { return@apply @@ -4973,6 +5212,16 @@ private constructor( 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(): Static = apply { if (validated) { return@apply @@ -5210,6 +5459,16 @@ private constructor( 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(): InnerStatic = apply { if (validated) { return@apply @@ -5359,6 +5618,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -5634,6 +5903,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -5792,6 +6070,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -5969,6 +6257,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply @@ -6215,6 +6513,15 @@ private constructor( 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(): TruncationStrategy = apply { if (validated) { return@apply @@ -6339,6 +6646,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt index d6f87f2b3..f8f7c2395 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadCreateParams.kt @@ -575,6 +575,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -902,6 +911,15 @@ private constructor( 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(): Message = apply { if (validated) { return@apply @@ -973,6 +991,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -983,6 +1031,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1243,6 +1301,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1443,6 +1511,16 @@ private constructor( 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(): Attachment = apply { if (validated) { return@apply @@ -1497,6 +1575,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tool.accept(new Tool.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -1506,6 +1614,16 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply @@ -1750,6 +1868,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1880,6 +2008,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2065,6 +2202,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -2223,6 +2369,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -2461,6 +2617,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply @@ -2740,6 +2906,16 @@ private constructor( 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(): VectorStore = apply { if (validated) { return@apply @@ -2806,6 +2982,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not + * known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chunkingStrategy.accept(new ChunkingStrategy.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -2815,6 +3022,16 @@ private constructor( 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(): ChunkingStrategy = apply { if (validated) { return@apply @@ -3132,6 +3349,16 @@ private constructor( 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(): Static = apply { if (validated) { return@apply @@ -3362,6 +3589,16 @@ private constructor( 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(): InnerStatic = apply { if (validated) { return@apply @@ -3508,6 +3745,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleted.kt index 8914152cf..919dcd1d4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadDeleted.kt @@ -187,6 +187,14 @@ private constructor( 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(): ThreadDeleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt index 3be9ac6f0..5be2c82cf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/ThreadUpdateParams.kt @@ -475,6 +475,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -591,6 +600,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -776,6 +794,15 @@ private constructor( 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(): ToolResources = apply { if (validated) { return@apply @@ -934,6 +961,16 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -1111,6 +1148,16 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Annotation.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Annotation.kt index bf4c31446..c8472d7ee 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Annotation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Annotation.kt @@ -64,6 +64,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = annotation.accept(new Annotation.Visitor>() { + * @Override + * public Optional visitFileCitation(FileCitationAnnotation fileCitation) { + * return Optional.of(fileCitation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileCitation != null -> visitor.visitFileCitation(fileCitation) @@ -73,6 +102,14 @@ private constructor( 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(): Annotation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/AnnotationDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/AnnotationDelta.kt index b68755eed..dc6886166 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/AnnotationDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/AnnotationDelta.kt @@ -64,6 +64,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = annotationDelta.accept(new AnnotationDelta.Visitor>() { + * @Override + * public Optional visitFileCitation(FileCitationDeltaAnnotation fileCitation) { + * return Optional.of(fileCitation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileCitation != null -> visitor.visitFileCitation(fileCitation) @@ -73,6 +102,14 @@ private constructor( 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(): AnnotationDelta = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationAnnotation.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationAnnotation.kt index 05fdf9756..c221249a5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationAnnotation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationAnnotation.kt @@ -265,6 +265,14 @@ private constructor( 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(): FileCitationAnnotation = apply { if (validated) { return@apply @@ -416,6 +424,15 @@ private constructor( 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(): FileCitation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationDeltaAnnotation.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationDeltaAnnotation.kt index b4985847b..f51feb40a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationDeltaAnnotation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FileCitationDeltaAnnotation.kt @@ -291,6 +291,14 @@ private constructor( 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(): FileCitationDeltaAnnotation = apply { if (validated) { return@apply @@ -461,6 +469,15 @@ private constructor( 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(): FileCitation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathAnnotation.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathAnnotation.kt index d20dbea28..897043f5a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathAnnotation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathAnnotation.kt @@ -258,6 +258,14 @@ private constructor( 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(): FilePathAnnotation = apply { if (validated) { return@apply @@ -409,6 +417,15 @@ private constructor( 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(): FilePath = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathDeltaAnnotation.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathDeltaAnnotation.kt index 08fc1ea69..ece6691d8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathDeltaAnnotation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/FilePathDeltaAnnotation.kt @@ -284,6 +284,14 @@ private constructor( 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(): FilePathDeltaAnnotation = apply { if (validated) { return@apply @@ -422,6 +430,15 @@ private constructor( 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(): FilePath = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFile.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFile.kt index 55db7d15d..326aaa7d5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFile.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFile.kt @@ -170,6 +170,14 @@ private constructor( 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(): ImageFile = apply { if (validated) { return@apply @@ -294,6 +302,15 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileContentBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileContentBlock.kt index a4a162e6f..619076507 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileContentBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileContentBlock.kt @@ -167,6 +167,14 @@ private constructor( 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(): ImageFileContentBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDelta.kt index c01b77f3c..da1e05405 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDelta.kt @@ -155,6 +155,14 @@ private constructor( 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(): ImageFileDelta = apply { if (validated) { return@apply @@ -279,6 +287,15 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDeltaBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDeltaBlock.kt index 7489a3cd5..224ec5067 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDeltaBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageFileDeltaBlock.kt @@ -201,6 +201,14 @@ private constructor( 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(): ImageFileDeltaBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrl.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrl.kt index 118148b0d..072c88675 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrl.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrl.kt @@ -167,6 +167,14 @@ private constructor( 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(): ImageUrl = apply { if (validated) { return@apply @@ -291,6 +299,15 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlContentBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlContentBlock.kt index 7d0e31e78..fe5fe025c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlContentBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlContentBlock.kt @@ -162,6 +162,14 @@ private constructor( 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(): ImageUrlContentBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDelta.kt index 39ad14169..e030074ff 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDelta.kt @@ -148,6 +148,14 @@ private constructor( 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(): ImageUrlDelta = apply { if (validated) { return@apply @@ -272,6 +280,15 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDeltaBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDeltaBlock.kt index d664180c5..9723779d2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDeltaBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/ImageUrlDeltaBlock.kt @@ -196,6 +196,14 @@ private constructor( 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(): ImageUrlDeltaBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Message.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Message.kt index d571fe4a9..06b4194cb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Message.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Message.kt @@ -782,6 +782,14 @@ private constructor( 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(): Message = apply { if (validated) { return@apply @@ -994,6 +1002,15 @@ private constructor( 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(): Attachment = apply { if (validated) { return@apply @@ -1051,6 +1068,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tool.accept(new Tool.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -1063,6 +1110,16 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply @@ -1371,6 +1428,15 @@ private constructor( 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(): IncompleteDetails = apply { if (validated) { return@apply @@ -1506,6 +1572,16 @@ private constructor( 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(): Reason = apply { if (validated) { return@apply @@ -1628,6 +1704,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1757,6 +1842,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1891,6 +1985,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContent.kt index e9119e6aa..101cbd8cc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContent.kt @@ -73,6 +73,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = messageContent.accept(new MessageContent.Visitor>() { + * @Override + * public Optional visitImageFile(ImageFileContentBlock imageFile) { + * return Optional.of(imageFile.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { imageFile != null -> visitor.visitImageFile(imageFile) @@ -84,6 +113,14 @@ private constructor( 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(): MessageContent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentDelta.kt index 13bc49cf5..a7b3113c2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentDelta.kt @@ -73,6 +73,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = messageContentDelta.accept(new MessageContentDelta.Visitor>() { + * @Override + * public Optional visitImageFile(ImageFileDeltaBlock imageFile) { + * return Optional.of(imageFile.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { imageFile != null -> visitor.visitImageFile(imageFile) @@ -84,6 +113,14 @@ private constructor( 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(): MessageContentDelta = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentPartParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentPartParam.kt index 2b556b4a0..4890698c4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentPartParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageContentPartParam.kt @@ -64,6 +64,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = messageContentPartParam.accept(new MessageContentPartParam.Visitor>() { + * @Override + * public Optional visitImageFile(ImageFileContentBlock imageFile) { + * return Optional.of(imageFile.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { imageFile != null -> visitor.visitImageFile(imageFile) @@ -74,6 +103,14 @@ private constructor( 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(): MessageContentPartParam = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt index 65fa37483..5f762e00a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageCreateParams.kt @@ -684,6 +684,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -778,6 +787,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -787,6 +825,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1040,6 +1087,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1233,6 +1289,15 @@ private constructor( 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(): Attachment = apply { if (validated) { return@apply @@ -1287,6 +1352,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tool.accept(new Tool.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -1296,6 +1391,16 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply @@ -1532,6 +1637,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleted.kt index fe6e2a711..cd6b51e72 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeleted.kt @@ -187,6 +187,14 @@ private constructor( 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(): MessageDeleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDelta.kt index 3e348fe6d..7415b75fa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDelta.kt @@ -229,6 +229,14 @@ private constructor( 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(): MessageDelta = apply { if (validated) { return@apply @@ -345,6 +353,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeltaEvent.kt index bff6c5528..ebbe83b72 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeltaEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageDeltaEvent.kt @@ -198,6 +198,14 @@ private constructor( 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(): MessageDeltaEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListPageResponse.kt index c37c51beb..bffca9945 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListPageResponse.kt @@ -265,6 +265,14 @@ private constructor( 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(): MessageListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListParams.kt index 602b26f1a..476698863 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageListParams.kt @@ -383,6 +383,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt index 7e9a11f12..1dc34892c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/MessageUpdateParams.kt @@ -402,6 +402,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -512,6 +521,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalContentBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalContentBlock.kt index 7c5de4f4b..33406e5ca 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalContentBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalContentBlock.kt @@ -160,6 +160,14 @@ private constructor( 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(): RefusalContentBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalDeltaBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalDeltaBlock.kt index 9f67ae7ba..36d3a7a65 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalDeltaBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/RefusalDeltaBlock.kt @@ -192,6 +192,14 @@ private constructor( 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(): RefusalDeltaBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Text.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Text.kt index c492dcc2a..39272754e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Text.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/Text.kt @@ -190,6 +190,14 @@ private constructor( 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(): Text = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlock.kt index 9a0447dcc..262510ae7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlock.kt @@ -157,6 +157,14 @@ private constructor( 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(): TextContentBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlockParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlockParam.kt index bbcc3af1a..2e4168315 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlockParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextContentBlockParam.kt @@ -163,6 +163,14 @@ private constructor( 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(): TextContentBlockParam = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDelta.kt index 37c89daa6..540824e98 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDelta.kt @@ -198,6 +198,14 @@ private constructor( 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(): TextDelta = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDeltaBlock.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDeltaBlock.kt index 1eca37381..49678d901 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDeltaBlock.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/messages/TextDeltaBlock.kt @@ -193,6 +193,14 @@ private constructor( 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(): TextDeltaBlock = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RequiredActionFunctionToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RequiredActionFunctionToolCall.kt index 324b1930f..06a0a86f6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RequiredActionFunctionToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RequiredActionFunctionToolCall.kt @@ -208,6 +208,14 @@ private constructor( 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(): RequiredActionFunctionToolCall = apply { if (validated) { return@apply @@ -395,6 +403,15 @@ private constructor( 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(): Function = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/Run.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/Run.kt index 9849f0d19..b372cceb6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/Run.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/Run.kt @@ -1439,6 +1439,14 @@ private constructor( 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(): Run = apply { if (validated) { return@apply @@ -1625,6 +1633,15 @@ private constructor( 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(): IncompleteDetails = apply { if (validated) { return@apply @@ -1745,6 +1762,16 @@ private constructor( 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(): Reason = apply { if (validated) { return@apply @@ -1952,6 +1979,15 @@ private constructor( 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(): LastError = apply { if (validated) { return@apply @@ -2077,6 +2113,16 @@ private constructor( 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(): Code = apply { if (validated) { return@apply @@ -2200,6 +2246,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2401,6 +2456,15 @@ private constructor( 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(): RequiredAction = apply { if (validated) { return@apply @@ -2577,6 +2641,16 @@ private constructor( 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(): SubmitToolOutputs = apply { if (validated) { return@apply @@ -2824,6 +2898,15 @@ private constructor( 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(): TruncationStrategy = apply { if (validated) { return@apply @@ -2948,6 +3031,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -3212,6 +3305,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt index 883e9d743..e8e5d679f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunCreateParams.kt @@ -2174,6 +2174,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -2558,6 +2567,15 @@ private constructor( 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(): AdditionalMessage = apply { if (validated) { return@apply @@ -2629,6 +2647,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -2639,6 +2687,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -2899,6 +2957,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -3099,6 +3167,16 @@ private constructor( 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(): Attachment = apply { if (validated) { return@apply @@ -3153,6 +3231,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tool.accept(new Tool.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterTool codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -3162,6 +3270,16 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply @@ -3406,6 +3524,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -3536,6 +3664,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -3758,6 +3895,15 @@ private constructor( 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(): TruncationStrategy = apply { if (validated) { return@apply @@ -3882,6 +4028,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListPageResponse.kt index 03d8eba21..78f78e893 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListPageResponse.kt @@ -262,6 +262,14 @@ private constructor( 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(): RunListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListParams.kt index 6492316c5..1944ea092 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunListParams.kt @@ -369,6 +369,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunStatus.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunStatus.kt index c28c6584e..0bcacd483 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunStatus.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/RunStatus.kt @@ -138,6 +138,14 @@ class RunStatus @JsonCreator private constructor(private val value: JsonField = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = output.accept(new Output.Visitor>() { + * @Override + * public Optional visitLogs(LogsOutput logs) { + * return Optional.of(logs.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { logs != null -> visitor.visitLogs(logs) @@ -518,6 +565,16 @@ private constructor( 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(): Output = apply { if (validated) { return@apply @@ -809,6 +866,16 @@ private constructor( 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(): LogsOutput = apply { if (validated) { return@apply @@ -1013,6 +1080,16 @@ private constructor( 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(): ImageOutput = apply { if (validated) { return@apply @@ -1176,6 +1253,16 @@ private constructor( 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(): Image = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/CodeInterpreterToolCallDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/CodeInterpreterToolCallDelta.kt index 4df9b2964..44652ee9f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/CodeInterpreterToolCallDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/CodeInterpreterToolCallDelta.kt @@ -249,6 +249,14 @@ private constructor( 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(): CodeInterpreterToolCallDelta = apply { if (validated) { return@apply @@ -470,6 +478,15 @@ private constructor( 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(): CodeInterpreter = apply { if (validated) { return@apply @@ -525,6 +542,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = output.accept(new Output.Visitor>() { + * @Override + * public Optional visitLogs(CodeInterpreterLogs logs) { + * return Optional.of(logs.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { logs != null -> visitor.visitLogs(logs) @@ -534,6 +581,16 @@ private constructor( 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(): Output = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCall.kt index 81e2c3aad..09a526e8e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCall.kt @@ -205,6 +205,14 @@ private constructor( 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(): FileSearchToolCall = apply { if (validated) { return@apply @@ -399,6 +407,15 @@ private constructor( 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(): FileSearch = apply { if (validated) { return@apply @@ -601,6 +618,16 @@ private constructor( 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(): RankingOptions = apply { if (validated) { return@apply @@ -726,6 +753,16 @@ private constructor( 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(): Ranker = apply { if (validated) { return@apply @@ -1038,6 +1075,16 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -1207,6 +1254,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1325,6 +1382,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCallDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCallDelta.kt index 36c1e94bc..64c05e59e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCallDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FileSearchToolCallDelta.kt @@ -214,6 +214,14 @@ private constructor( 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(): FileSearchToolCallDelta = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCall.kt index f6e9771c1..50d144806 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCall.kt @@ -198,6 +198,14 @@ private constructor( 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(): FunctionToolCall = apply { if (validated) { return@apply @@ -427,6 +435,15 @@ private constructor( 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(): Function = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCallDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCallDelta.kt index 2a59c6f33..5698202da 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCallDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/FunctionToolCallDelta.kt @@ -227,6 +227,14 @@ private constructor( 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(): FunctionToolCallDelta = apply { if (validated) { return@apply @@ -435,6 +443,15 @@ private constructor( 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(): Function = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/MessageCreationStepDetails.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/MessageCreationStepDetails.kt index 9b22b55b9..1db485140 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/MessageCreationStepDetails.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/MessageCreationStepDetails.kt @@ -169,6 +169,14 @@ private constructor( 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(): MessageCreationStepDetails = apply { if (validated) { return@apply @@ -319,6 +327,15 @@ private constructor( 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(): MessageCreation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStep.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStep.kt index ac122777b..48ad4a436 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStep.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStep.kt @@ -799,6 +799,14 @@ private constructor( 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(): RunStep = apply { if (validated) { return@apply @@ -1010,6 +1018,15 @@ private constructor( 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(): LastError = apply { if (validated) { return@apply @@ -1129,6 +1146,16 @@ private constructor( 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(): Code = apply { if (validated) { return@apply @@ -1252,6 +1279,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1402,6 +1438,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -1470,6 +1515,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = stepDetails.accept(new StepDetails.Visitor>() { + * @Override + * public Optional visitMessageCreation(MessageCreationStepDetails messageCreation) { + * return Optional.of(messageCreation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { messageCreation != null -> visitor.visitMessageCreation(messageCreation) @@ -1479,6 +1553,15 @@ private constructor( 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(): StepDetails = apply { if (validated) { return@apply @@ -1713,6 +1796,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -1958,6 +2050,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDelta.kt index 76c55b136..dd58c97c6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDelta.kt @@ -141,6 +141,14 @@ private constructor( 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(): RunStepDelta = apply { if (validated) { return@apply @@ -196,6 +204,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = stepDetails.accept(new StepDetails.Visitor>() { + * @Override + * public Optional visitMessageCreation(RunStepDeltaMessageDelta messageCreation) { + * return Optional.of(messageCreation.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { messageCreation != null -> visitor.visitMessageCreation(messageCreation) @@ -205,6 +242,15 @@ private constructor( 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(): StepDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaEvent.kt index 7a4a07c87..53ab73b65 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaEvent.kt @@ -198,6 +198,14 @@ private constructor( 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(): RunStepDeltaEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaMessageDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaMessageDelta.kt index 98234d42b..dad1a3e86 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaMessageDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepDeltaMessageDelta.kt @@ -152,6 +152,14 @@ private constructor( 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(): RunStepDeltaMessageDelta = apply { if (validated) { return@apply @@ -285,6 +293,15 @@ private constructor( 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(): MessageCreation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepInclude.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepInclude.kt index 451088fc4..6f25b7c53 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepInclude.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/RunStepInclude.kt @@ -92,6 +92,14 @@ class RunStepInclude @JsonCreator private constructor(private val value: JsonFie 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(): RunStepInclude = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListPageResponse.kt index a8d80fe7a..3822683ac 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListPageResponse.kt @@ -265,6 +265,14 @@ private constructor( 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(): StepListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListParams.kt index da4616564..997e7f31a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/StepListParams.kt @@ -433,6 +433,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCall.kt index c410289a6..a7dddbe6a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCall.kt @@ -51,6 +51,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = toolCall.accept(new ToolCall.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterToolCall codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -61,6 +90,14 @@ private constructor( 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(): ToolCall = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDelta.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDelta.kt index 82a738b79..05de8fdf2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDelta.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDelta.kt @@ -53,6 +53,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = toolCallDelta.accept(new ToolCallDelta.Visitor>() { + * @Override + * public Optional visitCodeInterpreter(CodeInterpreterToolCallDelta codeInterpreter) { + * return Optional.of(codeInterpreter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { codeInterpreter != null -> visitor.visitCodeInterpreter(codeInterpreter) @@ -63,6 +92,14 @@ private constructor( 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(): ToolCallDelta = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDeltaObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDeltaObject.kt index 85c4593b5..f8f2d6d71 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDeltaObject.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallDeltaObject.kt @@ -211,6 +211,14 @@ private constructor( 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(): ToolCallDeltaObject = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallsStepDetails.kt b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallsStepDetails.kt index c69ff8826..d27e03b85 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallsStepDetails.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/beta/threads/runs/steps/ToolCallsStepDetails.kt @@ -200,6 +200,14 @@ private constructor( 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(): ToolCallsStepDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt index 25b34f489..8a1861eaa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletion.kt @@ -446,6 +446,14 @@ private constructor( 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(): ChatCompletion = apply { if (validated) { return@apply @@ -736,6 +744,15 @@ private constructor( 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(): Choice = apply { if (validated) { return@apply @@ -887,6 +904,16 @@ private constructor( 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(): FinishReason = apply { if (validated) { return@apply @@ -1127,6 +1154,16 @@ private constructor( 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(): Logprobs = apply { if (validated) { return@apply @@ -1323,6 +1360,15 @@ private constructor( 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(): ServiceTier = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedToolChoice.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedToolChoice.kt index 569efc119..5cea7098c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedToolChoice.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedToolChoice.kt @@ -175,6 +175,14 @@ private constructor( 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(): ChatCompletionAllowedToolChoice = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedTools.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedTools.kt index 03bb6b733..f47dfa0ed 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedTools.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAllowedTools.kt @@ -209,6 +209,14 @@ private constructor( 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(): ChatCompletionAllowedTools = apply { if (validated) { return@apply @@ -331,6 +339,15 @@ private constructor( 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(): Mode = apply { if (validated) { return@apply @@ -428,6 +445,15 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAssistantMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAssistantMessageParam.kt index 725f75a89..2667584cd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAssistantMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAssistantMessageParam.kt @@ -411,6 +411,14 @@ private constructor( 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(): ChatCompletionAssistantMessageParam = apply { if (validated) { return@apply @@ -569,6 +577,15 @@ private constructor( 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(): Audio = apply { if (validated) { return@apply @@ -652,6 +669,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -661,6 +707,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -857,6 +912,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chatCompletionRequestAssistantMessageContentPart.accept(new ChatCompletionRequestAssistantMessageContentPart.Visitor>() { + * @Override + * public Optional visitText(ChatCompletionContentPartText text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -866,6 +951,16 @@ private constructor( 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(): ChatCompletionRequestAssistantMessageContentPart = apply { if (validated) { return@apply @@ -1216,6 +1311,15 @@ private constructor( 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(): FunctionCall = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudio.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudio.kt index b055d90d1..3bbd35ca3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudio.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudio.kt @@ -241,6 +241,14 @@ private constructor( 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(): ChatCompletionAudio = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt index 94eec100d..306e53122 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParam.kt @@ -200,6 +200,14 @@ private constructor( 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(): ChatCompletionAudioParam = apply { if (validated) { return@apply @@ -342,6 +350,15 @@ private constructor( 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(): Format = apply { if (validated) { return@apply @@ -417,6 +434,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = voice.accept(new Voice.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -427,6 +473,15 @@ private constructor( 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(): Voice = apply { if (validated) { return@apply @@ -726,6 +781,16 @@ private constructor( 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(): UnionMember1 = apply { if (validated) { return@apply @@ -881,6 +946,16 @@ private constructor( 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(): Id = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt index aada9f9c5..599e172f8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionChunk.kt @@ -472,6 +472,14 @@ private constructor( 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(): ChatCompletionChunk = apply { if (validated) { return@apply @@ -759,6 +767,15 @@ private constructor( 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(): Choice = apply { if (validated) { return@apply @@ -1068,6 +1085,16 @@ private constructor( 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(): Delta = apply { if (validated) { return@apply @@ -1257,6 +1284,16 @@ private constructor( 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(): FunctionCall = apply { if (validated) { return@apply @@ -1418,6 +1455,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1675,6 +1722,16 @@ private constructor( 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(): ToolCall = apply { if (validated) { return@apply @@ -1860,6 +1917,16 @@ private constructor( 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(): Function = apply { if (validated) { return@apply @@ -1999,6 +2066,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -2203,6 +2280,16 @@ private constructor( 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(): FinishReason = apply { if (validated) { return@apply @@ -2443,6 +2530,16 @@ private constructor( 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(): Logprobs = apply { if (validated) { return@apply @@ -2639,6 +2736,15 @@ private constructor( 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(): ServiceTier = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPart.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPart.kt index cff589e89..005dc662b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPart.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPart.kt @@ -78,6 +78,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chatCompletionContentPart.accept(new ChatCompletionContentPart.Visitor>() { + * @Override + * public Optional visitText(ChatCompletionContentPartText text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -89,6 +118,14 @@ private constructor( 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(): ChatCompletionContentPart = apply { if (validated) { return@apply @@ -430,6 +467,15 @@ private constructor( 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(): File = apply { if (validated) { return@apply @@ -638,6 +684,16 @@ private constructor( 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(): FileObject = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartImage.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartImage.kt index 48e9efbb0..c784800b8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartImage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartImage.kt @@ -166,6 +166,14 @@ private constructor( 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(): ChatCompletionContentPartImage = apply { if (validated) { return@apply @@ -346,6 +354,15 @@ private constructor( 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(): ImageUrl = apply { if (validated) { return@apply @@ -476,6 +493,16 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartInputAudio.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartInputAudio.kt index dcf2a01c7..f7ed7b5d5 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartInputAudio.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartInputAudio.kt @@ -171,6 +171,14 @@ private constructor( 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(): ChatCompletionContentPartInputAudio = apply { if (validated) { return@apply @@ -353,6 +361,15 @@ private constructor( 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(): InputAudio = apply { if (validated) { return@apply @@ -474,6 +491,16 @@ private constructor( 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(): Format = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartRefusal.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartRefusal.kt index c0055b8ff..fa4debe0f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartRefusal.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartRefusal.kt @@ -165,6 +165,14 @@ private constructor( 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(): ChatCompletionContentPartRefusal = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartText.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartText.kt index 382c40ca5..276b4d0fe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartText.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionContentPartText.kt @@ -164,6 +164,14 @@ private constructor( 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(): ChatCompletionContentPartText = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt index a972f9f37..315c32f5a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParams.kt @@ -421,9 +421,10 @@ private constructor( fun tools(): Optional> = body.tools() /** - * An integer between 0 and 20 specifying the number of most likely tokens to return at each - * token position, each with an associated log probability. `logprobs` must be set to `true` if - * this parameter is used. + * An integer between 0 and 20 specifying the maximum number of most likely tokens to return at + * each token position, each with an associated log probability. In some cases, the number of + * returned tokens may be fewer than requested. `logprobs` must be set to `true` if this + * parameter is used. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1803,8 +1804,9 @@ private constructor( ) = apply { addTool(functionToolFromClass(functionParametersType, localValidation)) } /** - * An integer between 0 and 20 specifying the number of most likely tokens to return at each - * token position, each with an associated log probability. `logprobs` must be set to `true` + * An integer between 0 and 20 specifying the maximum number of most likely tokens to return + * at each token position, each with an associated log probability. In some cases, the + * number of returned tokens may be fewer than requested. `logprobs` must be set to `true` * if this parameter is used. */ fun topLogprobs(topLogprobs: Long?) = apply { body.topLogprobs(topLogprobs) } @@ -2586,8 +2588,9 @@ private constructor( fun tools(): Optional> = tools.getOptional("tools") /** - * An integer between 0 and 20 specifying the number of most likely tokens to return at each - * token position, each with an associated log probability. `logprobs` must be set to `true` + * An integer between 0 and 20 specifying the maximum number of most likely tokens to return + * at each token position, each with an associated log probability. In some cases, the + * number of returned tokens may be fewer than requested. `logprobs` must be set to `true` * if this parameter is used. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -4117,9 +4120,10 @@ private constructor( addTool(ChatCompletionCustomTool.builder().custom(custom).build()) /** - * An integer between 0 and 20 specifying the number of most likely tokens to return at - * each token position, each with an associated log probability. `logprobs` must be set - * to `true` if this parameter is used. + * An integer between 0 and 20 specifying the maximum number of most likely tokens to + * return at each token position, each with an associated log probability. In some + * cases, the number of returned tokens may be fewer than requested. `logprobs` must be + * set to `true` if this parameter is used. */ fun topLogprobs(topLogprobs: Long?) = topLogprobs(JsonField.ofNullable(topLogprobs)) @@ -4300,6 +4304,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -4539,6 +4552,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = functionCall.accept(new FunctionCall.Visitor>() { + * @Override + * public Optional visitMode(FunctionCallMode mode) { + * return Optional.of(mode.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { mode != null -> visitor.visitMode(mode) @@ -4548,6 +4590,15 @@ private constructor( 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(): FunctionCall = apply { if (validated) { return@apply @@ -4812,6 +4863,16 @@ private constructor( 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(): FunctionCallMode = apply { if (validated) { return@apply @@ -5064,6 +5125,15 @@ private constructor( 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(): Function = apply { if (validated) { return@apply @@ -5184,6 +5254,15 @@ private constructor( 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(): LogitBias = apply { if (validated) { return@apply @@ -5291,6 +5370,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -5419,6 +5507,15 @@ private constructor( 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(): Modality = apply { if (validated) { return@apply @@ -5555,6 +5652,15 @@ private constructor( 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(): PromptCacheRetention = apply { if (validated) { return@apply @@ -5654,6 +5760,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = responseFormat.accept(new ResponseFormat.Visitor>() { + * @Override + * public Optional visitText(ResponseFormatText text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -5664,6 +5799,15 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply @@ -5970,6 +6114,15 @@ private constructor( 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(): ServiceTier = apply { if (validated) { return@apply @@ -6037,6 +6190,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = stop.accept(new Stop.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -6046,6 +6228,15 @@ private constructor( 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(): Stop = apply { if (validated) { return@apply @@ -6280,6 +6471,15 @@ private constructor( 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(): Verbosity = apply { if (validated) { return@apply @@ -6481,6 +6681,15 @@ private constructor( 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(): WebSearchOptions = apply { if (validated) { return@apply @@ -6615,6 +6824,16 @@ private constructor( 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(): SearchContextSize = apply { if (validated) { return@apply @@ -6813,6 +7032,16 @@ private constructor( 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(): UserLocation = apply { if (validated) { return@apply @@ -7070,6 +7299,16 @@ private constructor( 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(): Approximate = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCustomTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCustomTool.kt index bbc3e8ebd..667a733df 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCustomTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionCustomTool.kt @@ -176,6 +176,14 @@ private constructor( 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(): ChatCompletionCustomTool = apply { if (validated) { return@apply @@ -412,6 +420,15 @@ private constructor( 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(): Custom = apply { if (validated) { return@apply @@ -471,6 +488,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = format.accept(new Format.Visitor>() { + * @Override + * public Optional visitText(JsonValue text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -480,6 +527,16 @@ private constructor( 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(): Format = apply { if (validated) { return@apply @@ -782,6 +839,16 @@ private constructor( 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(): Grammar = apply { if (validated) { return@apply @@ -984,6 +1051,16 @@ private constructor( 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(): InnerGrammar = apply { if (validated) { return@apply @@ -1111,6 +1188,16 @@ private constructor( 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(): Syntax = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleted.kt index e129b9ac7..48f00d035 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeleted.kt @@ -195,6 +195,14 @@ private constructor( 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(): ChatCompletionDeleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeveloperMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeveloperMessageParam.kt index 9db1c7567..c8641c322 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeveloperMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionDeveloperMessageParam.kt @@ -228,6 +228,14 @@ private constructor( 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(): ChatCompletionDeveloperMessageParam = apply { if (validated) { return@apply @@ -298,6 +306,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -307,6 +344,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionCallOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionCallOption.kt index 7e480d8b6..defef2693 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionCallOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionCallOption.kt @@ -137,6 +137,14 @@ private constructor( 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(): ChatCompletionFunctionCallOption = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionMessageParam.kt index f1455a2a5..846418cbc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionMessageParam.kt @@ -204,6 +204,14 @@ private constructor( 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(): ChatCompletionFunctionMessageParam = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionTool.kt index c1fafc656..9803a0490 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionFunctionTool.kt @@ -167,6 +167,14 @@ private constructor( 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(): ChatCompletionFunctionTool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponse.kt index a186241df..e8c69e144 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListPageResponse.kt @@ -284,6 +284,14 @@ private constructor( 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(): ChatCompletionListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt index 302f3fa32..56c3d7ccd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionListParams.kt @@ -461,6 +461,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessage.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessage.kt index cdd540b6a..76b39ac91 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessage.kt @@ -432,6 +432,14 @@ private constructor( 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(): ChatCompletionMessage = apply { if (validated) { return@apply @@ -629,6 +637,15 @@ private constructor( 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(): Annotation = apply { if (validated) { return@apply @@ -896,6 +913,16 @@ private constructor( 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(): UrlCitation = apply { if (validated) { return@apply @@ -1136,6 +1163,15 @@ private constructor( 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(): FunctionCall = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageCustomToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageCustomToolCall.kt index 28479a973..25e2c9045 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageCustomToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageCustomToolCall.kt @@ -201,6 +201,14 @@ private constructor( 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(): ChatCompletionMessageCustomToolCall = apply { if (validated) { return@apply @@ -386,6 +394,15 @@ private constructor( 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(): Custom = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt index e3fd2ac65..3ebf99940 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageFunctionToolCall.kt @@ -203,6 +203,14 @@ private constructor( 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(): ChatCompletionMessageFunctionToolCall = apply { if (validated) { return@apply @@ -414,6 +422,15 @@ private constructor( 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(): Function = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageParam.kt index fa9e3e32f..d5e0848ba 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageParam.kt @@ -97,6 +97,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chatCompletionMessageParam.accept(new ChatCompletionMessageParam.Visitor>() { + * @Override + * public Optional visitDeveloper(ChatCompletionDeveloperMessageParam developer) { + * return Optional.of(developer.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { developer != null -> visitor.visitDeveloper(developer) @@ -110,6 +139,14 @@ private constructor( 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(): ChatCompletionMessageParam = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageToolCall.kt index 7501fa591..522746b89 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionMessageToolCall.kt @@ -46,6 +46,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chatCompletionMessageToolCall.accept(new ChatCompletionMessageToolCall.Visitor>() { + * @Override + * public Optional visitFunction(ChatCompletionMessageFunctionToolCall function) { + * return Optional.of(function.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { function != null -> visitor.visitFunction(function) @@ -55,6 +84,14 @@ private constructor( 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(): ChatCompletionMessageToolCall = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionModality.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionModality.kt index 6d75b4cb7..35f7b889c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionModality.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionModality.kt @@ -97,6 +97,14 @@ private constructor(private val value: JsonField) : Enum { 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(): ChatCompletionModality = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoice.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoice.kt index 438292e7b..81a12f66e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoice.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoice.kt @@ -163,6 +163,14 @@ private constructor( 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(): ChatCompletionNamedToolChoice = apply { if (validated) { return@apply @@ -308,6 +316,15 @@ private constructor( 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(): Function = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoiceCustom.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoiceCustom.kt index c1553c9db..e01706a57 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoiceCustom.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionNamedToolChoiceCustom.kt @@ -165,6 +165,14 @@ private constructor( 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(): ChatCompletionNamedToolChoiceCustom = apply { if (validated) { return@apply @@ -310,6 +318,15 @@ private constructor( 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(): Custom = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionPredictionContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionPredictionContent.kt index 09fa2bd01..52f5d2a96 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionPredictionContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionPredictionContent.kt @@ -196,6 +196,14 @@ private constructor( 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(): ChatCompletionPredictionContent = apply { if (validated) { return@apply @@ -275,6 +283,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -284,6 +321,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionRole.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionRole.kt index 30b47c14e..ac1ca0cd3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionRole.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionRole.kt @@ -121,6 +121,14 @@ class ChatCompletionRole @JsonCreator private constructor(private val value: Jso 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(): ChatCompletionRole = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStoreMessage.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStoreMessage.kt index 107150a02..50f2ed5e6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStoreMessage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStoreMessage.kt @@ -559,6 +559,14 @@ private constructor( 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(): ChatCompletionStoreMessage = apply { if (validated) { return@apply @@ -637,6 +645,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = contentPart.accept(new ContentPart.Visitor>() { + * @Override + * public Optional visitChatCompletionContentPartText(ChatCompletionContentPartText chatCompletionContentPartText) { + * return Optional.of(chatCompletionContentPartText.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatCompletionContentPartText != null -> @@ -648,6 +685,15 @@ private constructor( 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(): ContentPart = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStreamOptions.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStreamOptions.kt index ac3bf9066..7bfde6e27 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStreamOptions.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionStreamOptions.kt @@ -193,6 +193,14 @@ private constructor( 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(): ChatCompletionStreamOptions = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionSystemMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionSystemMessageParam.kt index 1b87abd09..bb871bb00 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionSystemMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionSystemMessageParam.kt @@ -227,6 +227,14 @@ private constructor( 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(): ChatCompletionSystemMessageParam = apply { if (validated) { return@apply @@ -297,6 +305,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -306,6 +343,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTokenLogprob.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTokenLogprob.kt index aecc073ba..a70c96880 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTokenLogprob.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTokenLogprob.kt @@ -68,8 +68,8 @@ private constructor( fun logprob(): Double = logprob.getRequired("logprob") /** - * List of the most likely tokens and their log probability, at this token position. In rare - * cases, there may be fewer than the number of requested `top_logprobs` returned. + * List of the most likely tokens and their log probability, at this token position. The number + * of entries may be fewer than the requested `top_logprobs`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -210,8 +210,8 @@ private constructor( fun logprob(logprob: JsonField) = apply { this.logprob = logprob } /** - * List of the most likely tokens and their log probability, at this token position. In rare - * cases, there may be fewer than the number of requested `top_logprobs` returned. + * List of the most likely tokens and their log probability, at this token position. The + * number of entries may be fewer than the requested `top_logprobs`. */ fun topLogprobs(topLogprobs: List) = topLogprobs(JsonField.of(topLogprobs)) @@ -284,6 +284,14 @@ private constructor( 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(): ChatCompletionTokenLogprob = apply { if (validated) { return@apply @@ -529,6 +537,15 @@ private constructor( 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(): TopLogprob = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTool.kt index 8a31caa71..6fd1a00b1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionTool.kt @@ -46,6 +46,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chatCompletionTool.accept(new ChatCompletionTool.Visitor>() { + * @Override + * public Optional visitFunction(ChatCompletionFunctionTool function) { + * return Optional.of(function.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { function != null -> visitor.visitFunction(function) @@ -55,6 +84,14 @@ private constructor( 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(): ChatCompletionTool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolChoiceOption.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolChoiceOption.kt index b35392952..2921ff310 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolChoiceOption.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolChoiceOption.kt @@ -97,6 +97,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = chatCompletionToolChoiceOption.accept(new ChatCompletionToolChoiceOption.Visitor>() { + * @Override + * public Optional visitAuto(Auto auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -109,6 +138,14 @@ private constructor( 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(): ChatCompletionToolChoiceOption = apply { if (validated) { return@apply @@ -437,6 +474,15 @@ private constructor( 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(): Auto = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt index 9331d62f4..7964135c4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionToolMessageParam.kt @@ -232,6 +232,14 @@ private constructor( 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(): ChatCompletionToolMessageParam = apply { if (validated) { return@apply @@ -302,6 +310,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -311,6 +348,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt index ba81c82e4..674300252 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUpdateParams.kt @@ -411,6 +411,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -521,6 +530,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUserMessageParam.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUserMessageParam.kt index 524dff634..6746c69b1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUserMessageParam.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/ChatCompletionUserMessageParam.kt @@ -223,6 +223,14 @@ private constructor( 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(): ChatCompletionUserMessageParam = apply { if (validated) { return@apply @@ -295,6 +303,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitText(String text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -304,6 +341,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListPageResponse.kt index 34e4234b6..600edb9c9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListPageResponse.kt @@ -285,6 +285,14 @@ private constructor( 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(): MessageListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListParams.kt index c4924203e..c61578b6a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/chat/completions/messages/MessageListParams.kt @@ -333,6 +333,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/completions/Completion.kt b/openai-java-core/src/main/kotlin/com/openai/models/completions/Completion.kt index 9d116cea8..69e3ad9b0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/completions/Completion.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/completions/Completion.kt @@ -368,6 +368,14 @@ private constructor( 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(): Completion = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionChoice.kt b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionChoice.kt index e7c5ca159..7ced7613b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionChoice.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionChoice.kt @@ -244,6 +244,14 @@ private constructor( 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(): CompletionChoice = apply { if (validated) { return@apply @@ -378,6 +386,15 @@ private constructor( 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(): FinishReason = apply { if (validated) { return@apply @@ -674,6 +691,15 @@ private constructor( 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(): Logprobs = apply { if (validated) { return@apply @@ -768,6 +794,16 @@ private constructor( 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(): TopLogprob = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt index 3bac4ec72..b44336ddd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionCreateParams.kt @@ -2027,6 +2027,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -2240,6 +2249,15 @@ private constructor( 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(): Model = apply { if (validated) { return@apply @@ -2324,6 +2342,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = prompt.accept(new Prompt.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2335,6 +2382,15 @@ private constructor( 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(): Prompt = apply { if (validated) { return@apply @@ -2581,6 +2637,15 @@ private constructor( 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(): LogitBias = apply { if (validated) { return@apply @@ -2651,6 +2716,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = stop.accept(new Stop.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -2660,6 +2754,15 @@ private constructor( 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(): Stop = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt index 41c962210..7acabe460 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/completions/CompletionUsage.kt @@ -306,6 +306,14 @@ private constructor( 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(): CompletionUsage = apply { if (validated) { return@apply @@ -588,6 +596,15 @@ private constructor( 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(): CompletionTokensDetails = apply { if (validated) { return@apply @@ -792,6 +809,15 @@ private constructor( 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(): PromptTokensDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt index 9cfad3130..148cab8ae 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateParams.kt @@ -827,6 +827,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1047,6 +1056,15 @@ private constructor( 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(): ExpiresAfter = apply { if (validated) { return@apply @@ -1162,6 +1180,16 @@ private constructor( 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(): Anchor = apply { if (validated) { return@apply @@ -1322,6 +1350,15 @@ private constructor( 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(): MemoryLimit = apply { if (validated) { return@apply @@ -1384,6 +1421,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = networkPolicy.accept(new NetworkPolicy.Visitor>() { + * @Override + * public Optional visitDisabled(ContainerNetworkPolicyDisabled disabled) { + * return Optional.of(disabled.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { disabled != null -> visitor.visitDisabled(disabled) @@ -1393,6 +1459,15 @@ private constructor( 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(): NetworkPolicy = apply { if (validated) { return@apply @@ -1565,6 +1640,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = skill.accept(new Skill.Visitor>() { + * @Override + * public Optional visitReference(SkillReference reference) { + * return Optional.of(reference.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { reference != null -> visitor.visitReference(reference) @@ -1574,6 +1678,15 @@ private constructor( 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(): Skill = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt index f55604448..507a850a3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerCreateResponse.kt @@ -434,6 +434,14 @@ private constructor( 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(): ContainerCreateResponse = apply { if (validated) { return@apply @@ -611,6 +619,15 @@ private constructor( 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(): ExpiresAfter = apply { if (validated) { return@apply @@ -726,6 +743,16 @@ private constructor( 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(): Anchor = apply { if (validated) { return@apply @@ -886,6 +913,15 @@ private constructor( 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(): MemoryLimit = apply { if (validated) { return@apply @@ -1093,6 +1129,15 @@ private constructor( 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(): NetworkPolicy = apply { if (validated) { return@apply @@ -1212,6 +1257,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListPageResponse.kt index 85e9a8c77..0cb31d06c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListPageResponse.kt @@ -281,6 +281,14 @@ private constructor( 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(): ContainerListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt index a81fb2210..ca2c15b6d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListParams.kt @@ -342,6 +342,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt index e1b54962b..ac1065d61 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerListResponse.kt @@ -434,6 +434,14 @@ private constructor( 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(): ContainerListResponse = apply { if (validated) { return@apply @@ -611,6 +619,15 @@ private constructor( 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(): ExpiresAfter = apply { if (validated) { return@apply @@ -726,6 +743,16 @@ private constructor( 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(): Anchor = apply { if (validated) { return@apply @@ -886,6 +913,15 @@ private constructor( 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(): MemoryLimit = apply { if (validated) { return@apply @@ -1093,6 +1129,15 @@ private constructor( 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(): NetworkPolicy = apply { if (validated) { return@apply @@ -1212,6 +1257,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt index 9c05fc02d..8d34bd90f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/ContainerRetrieveResponse.kt @@ -434,6 +434,14 @@ private constructor( 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(): ContainerRetrieveResponse = apply { if (validated) { return@apply @@ -611,6 +619,15 @@ private constructor( 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(): ExpiresAfter = apply { if (validated) { return@apply @@ -726,6 +743,16 @@ private constructor( 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(): Anchor = apply { if (validated) { return@apply @@ -886,6 +913,15 @@ private constructor( 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(): MemoryLimit = apply { if (validated) { return@apply @@ -1093,6 +1129,15 @@ private constructor( 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(): NetworkPolicy = apply { if (validated) { return@apply @@ -1212,6 +1257,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateParams.kt index 745c25afa..f3403d16b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateParams.kt @@ -426,6 +426,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateResponse.kt index 243b2b472..a499364b2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileCreateResponse.kt @@ -332,6 +332,14 @@ private constructor( 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(): FileCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListPageResponse.kt index 5980b196c..84ec340f9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListPageResponse.kt @@ -281,6 +281,14 @@ private constructor( 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(): FileListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListParams.kt index 054617dcf..22fcc0cdd 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListParams.kt @@ -345,6 +345,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListResponse.kt index 2b1e6da77..e4904b1cb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileListResponse.kt @@ -332,6 +332,14 @@ private constructor( 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(): FileListResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileRetrieveResponse.kt index 7077abba2..323a31ce7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/containers/files/FileRetrieveResponse.kt @@ -332,6 +332,14 @@ private constructor( 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(): FileRetrieveResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt index 1db895140..3159c5a1b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ComputerScreenshotContent.kt @@ -243,6 +243,14 @@ private constructor( 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(): ComputerScreenshotContent = apply { if (validated) { return@apply @@ -382,6 +390,15 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/Conversation.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/Conversation.kt index cc6075c5c..392330370 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/Conversation.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/Conversation.kt @@ -225,6 +225,14 @@ private constructor( 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(): Conversation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt index 408c0653a..c5f016f47 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationCreateParams.kt @@ -924,6 +924,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1038,6 +1047,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeleted.kt index 3dd4ab476..fb11b97ca 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeleted.kt @@ -187,6 +187,14 @@ private constructor( 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(): ConversationDeleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeletedResource.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeletedResource.kt index a4c5012db..d5b1e2df2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeletedResource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationDeletedResource.kt @@ -187,6 +187,14 @@ private constructor( 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(): ConversationDeletedResource = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationUpdateParams.kt index 386e0cfea..22ef906d7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/ConversationUpdateParams.kt @@ -408,6 +408,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -518,6 +527,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt index bd0496273..b6fdd1907 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/Message.kt @@ -448,6 +448,14 @@ private constructor( 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(): Message = apply { if (validated) { return@apply @@ -587,6 +595,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitInputText(ResponseInputText inputText) { + * return Optional.of(inputText.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { inputText != null -> visitor.visitInputText(inputText) @@ -603,6 +640,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1070,6 +1116,16 @@ private constructor( 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(): ReasoningText = apply { if (validated) { return@apply @@ -1250,6 +1306,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1385,6 +1450,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -1516,6 +1590,15 @@ private constructor( 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(): Phase = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt index caae797cb..fb96bc82e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/SummaryTextContent.kt @@ -163,6 +163,14 @@ private constructor( 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(): SummaryTextContent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt index d1a1736bd..f5afcd35e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/TextContent.kt @@ -154,6 +154,14 @@ private constructor( 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(): TextContent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt index edb3b96c8..dfa3cdf6c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItem.kt @@ -348,6 +348,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = conversationItem.accept(new ConversationItem.Visitor>() { + * @Override + * public Optional visitMessage(Message message) { + * return Optional.of(message.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { message != null -> visitor.visitMessage(message) @@ -380,6 +409,14 @@ private constructor( 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(): ConversationItem = apply { if (validated) { return@apply @@ -1371,6 +1408,15 @@ private constructor( 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(): ImageGenerationCall = apply { if (validated) { return@apply @@ -1512,6 +1558,16 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -1824,6 +1880,15 @@ private constructor( 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(): LocalShellCall = apply { if (validated) { return@apply @@ -2199,6 +2264,16 @@ private constructor( 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(): Action = apply { if (validated) { return@apply @@ -2302,6 +2377,16 @@ private constructor( 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(): Env = apply { if (validated) { return@apply @@ -2476,6 +2561,16 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -2756,6 +2851,15 @@ private constructor( 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(): LocalShellCallOutput = apply { if (validated) { return@apply @@ -2891,6 +2995,16 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -3224,6 +3338,15 @@ private constructor( 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(): McpListTools = apply { if (validated) { return@apply @@ -3474,6 +3597,16 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply @@ -3809,6 +3942,15 @@ private constructor( 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(): McpApprovalRequest = apply { if (validated) { return@apply @@ -4132,6 +4274,15 @@ private constructor( 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(): McpApprovalResponse = apply { if (validated) { return@apply @@ -4624,6 +4775,15 @@ private constructor( 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(): McpCall = apply { if (validated) { return@apply @@ -4784,6 +4944,16 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItemList.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItemList.kt index c8d4ee41f..b9cc66a6f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItemList.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ConversationItemList.kt @@ -430,6 +430,14 @@ private constructor( 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(): ConversationItemList = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt index 9f4c47777..ef58c910e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemCreateParams.kt @@ -903,6 +903,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemListParams.kt index fc7a780c9..7fd883572 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/conversations/items/ItemListParams.kt @@ -397,6 +397,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/CreateEmbeddingResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/CreateEmbeddingResponse.kt index cea66c5a3..61f498e02 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/CreateEmbeddingResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/CreateEmbeddingResponse.kt @@ -246,6 +246,14 @@ private constructor( 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(): CreateEmbeddingResponse = apply { if (validated) { return@apply @@ -444,6 +452,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt index 89732240f..ff616ce31 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/Embedding.kt @@ -257,6 +257,14 @@ private constructor( 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(): Embedding = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt index 65c817d3d..d60d83d59 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingCreateParams.kt @@ -755,6 +755,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -870,6 +879,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = input.accept(new Input.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -881,6 +919,15 @@ private constructor( 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(): Input = apply { if (validated) { return@apply @@ -1159,6 +1206,15 @@ private constructor( 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(): EncodingFormat = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingModel.kt index 34c7ecc85..45fa23f08 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/embeddings/EmbeddingModel.kt @@ -100,6 +100,14 @@ class EmbeddingModel @JsonCreator private constructor(private val value: JsonFie 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(): EmbeddingModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt index 3987a8bda..2ca46e6d7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateParams.kt @@ -790,6 +790,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -906,6 +915,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSourceConfig.accept(new DataSourceConfig.Visitor>() { + * @Override + * public Optional visitCustom(Custom custom) { + * return Optional.of(custom.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { custom != null -> visitor.visitCustom(custom) @@ -916,6 +954,15 @@ private constructor( 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(): DataSourceConfig = apply { if (validated) { return@apply @@ -1311,6 +1358,16 @@ private constructor( 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(): Custom = apply { if (validated) { return@apply @@ -1408,6 +1465,16 @@ private constructor( 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(): ItemSchema = apply { if (validated) { return@apply @@ -1614,6 +1681,16 @@ private constructor( 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(): Logs = apply { if (validated) { return@apply @@ -1709,6 +1786,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1913,6 +2000,16 @@ private constructor( 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(): StoredCompletions = apply { if (validated) { return@apply @@ -2008,6 +2105,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2140,6 +2247,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = testingCriterion.accept(new TestingCriterion.Visitor>() { + * @Override + * public Optional visitLabelModel(LabelModel labelModel) { + * return Optional.of(labelModel.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { labelModel != null -> visitor.visitLabelModel(labelModel) @@ -2152,6 +2288,15 @@ private constructor( 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(): TestingCriterion = apply { if (validated) { return@apply @@ -2735,6 +2880,16 @@ private constructor( 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(): LabelModel = apply { if (validated) { return@apply @@ -2819,6 +2974,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = input.accept(new Input.Visitor>() { + * @Override + * public Optional visitSimpleInputMessage(SimpleInputMessage simpleInputMessage) { + * return Optional.of(simpleInputMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { simpleInputMessage != null -> @@ -2829,6 +3014,16 @@ private constructor( 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(): Input = apply { if (validated) { return@apply @@ -3160,6 +3355,16 @@ private constructor( 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(): SimpleInputMessage = apply { if (validated) { return@apply @@ -3457,6 +3662,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -3568,6 +3783,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -3583,6 +3829,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -4023,6 +4279,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -4290,6 +4556,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -4462,6 +4738,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -4592,6 +4878,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -5010,6 +5306,16 @@ private constructor( 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(): TextSimilarity = apply { if (validated) { return@apply @@ -5357,6 +5663,16 @@ private constructor( 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(): Python = apply { if (validated) { return@apply @@ -5806,6 +6122,16 @@ private constructor( 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(): ScoreModel = apply { if (validated) { return@apply @@ -5951,6 +6277,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateResponse.kt index d76a9720b..fab8eb4cf 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCreateResponse.kt @@ -498,6 +498,14 @@ private constructor( 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(): EvalCreateResponse = apply { if (validated) { return@apply @@ -601,6 +609,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSourceConfig.accept(new DataSourceConfig.Visitor>() { + * @Override + * public Optional visitCustom(EvalCustomDataSourceConfig custom) { + * return Optional.of(custom.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { custom != null -> visitor.visitCustom(custom) @@ -611,6 +648,15 @@ private constructor( 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(): DataSourceConfig = apply { if (validated) { return@apply @@ -1023,6 +1069,16 @@ private constructor( 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(): Logs = apply { if (validated) { return@apply @@ -1123,6 +1179,16 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply @@ -1235,6 +1301,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1367,6 +1443,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1483,6 +1568,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = testingCriterion.accept(new TestingCriterion.Visitor>() { + * @Override + * public Optional visitLabelModelGrader(LabelModelGrader labelModelGrader) { + * return Optional.of(labelModelGrader.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { labelModelGrader != null -> visitor.visitLabelModelGrader(labelModelGrader) @@ -1497,6 +1611,15 @@ private constructor( 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(): TestingCriterion = apply { if (validated) { return@apply @@ -2077,6 +2200,16 @@ private constructor( 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(): EvalGraderTextSimilarity = apply { if (validated) { return@apply @@ -2424,6 +2557,16 @@ private constructor( 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(): EvalGraderPython = apply { if (validated) { return@apply @@ -2873,6 +3016,16 @@ private constructor( 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(): EvalGraderScoreModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCustomDataSourceConfig.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCustomDataSourceConfig.kt index 0f1384894..903c4c797 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCustomDataSourceConfig.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalCustomDataSourceConfig.kt @@ -174,6 +174,14 @@ private constructor( 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(): EvalCustomDataSourceConfig = apply { if (validated) { return@apply @@ -268,6 +276,15 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalDeleteResponse.kt index 3594faa12..d50d6da4d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalDeleteResponse.kt @@ -187,6 +187,14 @@ private constructor( 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(): EvalDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListPageResponse.kt index 46c6ff8ce..2b357d021 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListPageResponse.kt @@ -282,6 +282,14 @@ private constructor( 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(): EvalListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListParams.kt index 1b4ee0ec7..2d5abef5f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListParams.kt @@ -333,6 +333,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply @@ -462,6 +471,15 @@ private constructor( 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(): OrderBy = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListResponse.kt index 49f7c34e7..27f57f2e6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalListResponse.kt @@ -498,6 +498,14 @@ private constructor( 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(): EvalListResponse = apply { if (validated) { return@apply @@ -601,6 +609,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSourceConfig.accept(new DataSourceConfig.Visitor>() { + * @Override + * public Optional visitCustom(EvalCustomDataSourceConfig custom) { + * return Optional.of(custom.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { custom != null -> visitor.visitCustom(custom) @@ -611,6 +648,15 @@ private constructor( 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(): DataSourceConfig = apply { if (validated) { return@apply @@ -1023,6 +1069,16 @@ private constructor( 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(): Logs = apply { if (validated) { return@apply @@ -1123,6 +1179,16 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply @@ -1235,6 +1301,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1367,6 +1443,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1483,6 +1568,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = testingCriterion.accept(new TestingCriterion.Visitor>() { + * @Override + * public Optional visitLabelModelGrader(LabelModelGrader labelModelGrader) { + * return Optional.of(labelModelGrader.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { labelModelGrader != null -> visitor.visitLabelModelGrader(labelModelGrader) @@ -1497,6 +1611,15 @@ private constructor( 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(): TestingCriterion = apply { if (validated) { return@apply @@ -2077,6 +2200,16 @@ private constructor( 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(): EvalGraderTextSimilarity = apply { if (validated) { return@apply @@ -2424,6 +2557,16 @@ private constructor( 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(): EvalGraderPython = apply { if (validated) { return@apply @@ -2873,6 +3016,16 @@ private constructor( 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(): EvalGraderScoreModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalRetrieveResponse.kt index 2f89b702c..a611ed335 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalRetrieveResponse.kt @@ -498,6 +498,14 @@ private constructor( 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(): EvalRetrieveResponse = apply { if (validated) { return@apply @@ -601,6 +609,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSourceConfig.accept(new DataSourceConfig.Visitor>() { + * @Override + * public Optional visitCustom(EvalCustomDataSourceConfig custom) { + * return Optional.of(custom.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { custom != null -> visitor.visitCustom(custom) @@ -611,6 +648,15 @@ private constructor( 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(): DataSourceConfig = apply { if (validated) { return@apply @@ -1023,6 +1069,16 @@ private constructor( 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(): Logs = apply { if (validated) { return@apply @@ -1123,6 +1179,16 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply @@ -1235,6 +1301,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1367,6 +1443,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1483,6 +1568,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = testingCriterion.accept(new TestingCriterion.Visitor>() { + * @Override + * public Optional visitLabelModelGrader(LabelModelGrader labelModelGrader) { + * return Optional.of(labelModelGrader.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { labelModelGrader != null -> visitor.visitLabelModelGrader(labelModelGrader) @@ -1497,6 +1611,15 @@ private constructor( 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(): TestingCriterion = apply { if (validated) { return@apply @@ -2077,6 +2200,16 @@ private constructor( 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(): EvalGraderTextSimilarity = apply { if (validated) { return@apply @@ -2424,6 +2557,16 @@ private constructor( 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(): EvalGraderPython = apply { if (validated) { return@apply @@ -2873,6 +3016,16 @@ private constructor( 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(): EvalGraderScoreModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalStoredCompletionsDataSourceConfig.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalStoredCompletionsDataSourceConfig.kt index 7132027fb..3bd3b0823 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalStoredCompletionsDataSourceConfig.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalStoredCompletionsDataSourceConfig.kt @@ -222,6 +222,14 @@ private constructor( 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(): EvalStoredCompletionsDataSourceConfig = apply { if (validated) { return@apply @@ -318,6 +326,15 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply @@ -425,6 +442,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateParams.kt index 21dd04055..c46215444 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateParams.kt @@ -437,6 +437,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -551,6 +560,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateResponse.kt index afd92d5f7..4fa25596f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/EvalUpdateResponse.kt @@ -498,6 +498,14 @@ private constructor( 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(): EvalUpdateResponse = apply { if (validated) { return@apply @@ -601,6 +609,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSourceConfig.accept(new DataSourceConfig.Visitor>() { + * @Override + * public Optional visitCustom(EvalCustomDataSourceConfig custom) { + * return Optional.of(custom.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { custom != null -> visitor.visitCustom(custom) @@ -611,6 +648,15 @@ private constructor( 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(): DataSourceConfig = apply { if (validated) { return@apply @@ -1023,6 +1069,16 @@ private constructor( 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(): Logs = apply { if (validated) { return@apply @@ -1123,6 +1179,16 @@ private constructor( 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(): Schema = apply { if (validated) { return@apply @@ -1235,6 +1301,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1367,6 +1443,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1483,6 +1568,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = testingCriterion.accept(new TestingCriterion.Visitor>() { + * @Override + * public Optional visitLabelModelGrader(LabelModelGrader labelModelGrader) { + * return Optional.of(labelModelGrader.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { labelModelGrader != null -> visitor.visitLabelModelGrader(labelModelGrader) @@ -1497,6 +1611,15 @@ private constructor( 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(): TestingCriterion = apply { if (validated) { return@apply @@ -2077,6 +2200,16 @@ private constructor( 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(): EvalGraderTextSimilarity = apply { if (validated) { return@apply @@ -2424,6 +2557,16 @@ private constructor( 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(): EvalGraderPython = apply { if (validated) { return@apply @@ -2873,6 +3016,16 @@ private constructor( 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(): EvalGraderScoreModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt index ea9b67b58..1af34990e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalCompletionsRunDataSource.kt @@ -368,6 +368,14 @@ private constructor( 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(): CreateEvalCompletionsRunDataSource = apply { if (validated) { return@apply @@ -437,6 +445,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -447,6 +484,15 @@ private constructor( 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 @@ -775,6 +821,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -958,6 +1014,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1049,6 +1115,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -1154,6 +1230,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -1385,6 +1471,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply @@ -1776,6 +1872,16 @@ private constructor( 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(): StoredCompletions = apply { if (validated) { return@apply @@ -1886,6 +1992,16 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2045,6 +2161,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -2111,6 +2236,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = inputMessages.accept(new InputMessages.Visitor>() { + * @Override + * public Optional visitTemplate(Template template) { + * return Optional.of(template.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { template != null -> visitor.visitTemplate(template) @@ -2120,6 +2274,15 @@ private constructor( 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(): InputMessages = apply { if (validated) { return@apply @@ -2445,6 +2608,16 @@ private constructor( 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(): Template = apply { if (validated) { return@apply @@ -2537,6 +2710,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerTemplate.accept(new InnerTemplate.Visitor>() { + * @Override + * public Optional visitEasyInputMessage(EasyInputMessage easyInputMessage) { + * return Optional.of(easyInputMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { easyInputMessage != null -> visitor.visitEasyInputMessage(easyInputMessage) @@ -2546,6 +2749,16 @@ private constructor( 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(): InnerTemplate = apply { if (validated) { return@apply @@ -2972,6 +3185,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -3083,6 +3306,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -3098,6 +3352,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -3538,6 +3802,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -3805,6 +4079,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -3977,6 +4261,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -4107,6 +4401,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -4350,6 +4654,16 @@ private constructor( 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(): ItemReference = apply { if (validated) { return@apply @@ -4828,6 +5142,15 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply @@ -4930,6 +5253,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = responseFormat.accept(new ResponseFormat.Visitor>() { + * @Override + * public Optional visitText(ResponseFormatText text) { + * return Optional.of(text.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { text != null -> visitor.visitText(text) @@ -4940,6 +5293,16 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalJsonlRunDataSource.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalJsonlRunDataSource.kt index 9b6a08a70..868d11e9a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalJsonlRunDataSource.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/CreateEvalJsonlRunDataSource.kt @@ -204,6 +204,14 @@ private constructor( 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(): CreateEvalJsonlRunDataSource = apply { if (validated) { return@apply @@ -260,6 +268,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -269,6 +306,15 @@ private constructor( 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 @@ -571,6 +617,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -754,6 +810,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -845,6 +911,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -950,6 +1026,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -1181,6 +1267,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/EvalApiError.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/EvalApiError.kt index bed615b66..8c7cdb174 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/EvalApiError.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/EvalApiError.kt @@ -164,6 +164,14 @@ private constructor( 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(): EvalApiError = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt index 310b9b65d..85165ccb7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCancelResponse.kt @@ -887,6 +887,14 @@ private constructor( 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(): RunCancelResponse = apply { if (validated) { return@apply @@ -983,6 +991,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSource.accept(new DataSource.Visitor>() { + * @Override + * public Optional visitJsonl(CreateEvalJsonlRunDataSource jsonl) { + * return Optional.of(jsonl.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { jsonl != null -> visitor.visitJsonl(jsonl) @@ -993,6 +1030,15 @@ private constructor( 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(): DataSource = apply { if (validated) { return@apply @@ -1502,6 +1548,16 @@ private constructor( 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(): Responses = apply { if (validated) { return@apply @@ -1574,6 +1630,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -1584,6 +1670,16 @@ private constructor( 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 @@ -1917,6 +2013,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -2106,6 +2212,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -2202,6 +2318,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -2316,6 +2442,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -2559,6 +2695,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply @@ -3268,6 +3414,16 @@ private constructor( 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(): InnerResponses = apply { if (validated) { return@apply @@ -3390,6 +3546,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = inputMessages.accept(new InputMessages.Visitor>() { + * @Override + * public Optional visitTemplate(Template template) { + * return Optional.of(template.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { template != null -> visitor.visitTemplate(template) @@ -3399,6 +3585,16 @@ private constructor( 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(): InputMessages = apply { if (validated) { return@apply @@ -3733,6 +3929,16 @@ private constructor( 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(): Template = apply { if (validated) { return@apply @@ -3810,6 +4016,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerTemplate.accept(new InnerTemplate.Visitor>() { + * @Override + * public Optional visitChatMessage(ChatMessage chatMessage) { + * return Optional.of(chatMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatMessage != null -> visitor.visitChatMessage(chatMessage) @@ -3819,6 +4056,16 @@ private constructor( 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(): InnerTemplate = apply { if (validated) { return@apply @@ -4160,6 +4407,16 @@ private constructor( 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(): ChatMessage = apply { if (validated) { return@apply @@ -4479,6 +4736,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -4592,6 +4859,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using + * the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new + * variants from the API, unless [visitor] overrides + * [Visitor.unknown]. To handle variants not known to this version + * of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not + * overridden in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -4608,6 +4906,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -5094,6 +5402,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -5377,6 +5695,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -5558,6 +5886,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -5696,6 +6034,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -5942,6 +6290,16 @@ private constructor( 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(): ItemReference = apply { if (validated) { return@apply @@ -6544,6 +6902,16 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply @@ -6745,6 +7113,16 @@ private constructor( 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(): Text = apply { if (validated) { return@apply @@ -6922,6 +7300,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -7293,6 +7680,15 @@ private constructor( 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(): PerModelUsage = apply { if (validated) { return@apply @@ -7555,6 +7951,15 @@ private constructor( 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(): PerTestingCriteriaResult = apply { if (validated) { return@apply @@ -7827,6 +8232,15 @@ private constructor( 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(): ResultCounts = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt index a4cfb63ac..8a30d2adb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateParams.kt @@ -618,6 +618,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -714,6 +723,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSource.accept(new DataSource.Visitor>() { + * @Override + * public Optional visitCreateEvalJsonlRun(CreateEvalJsonlRunDataSource createEvalJsonlRun) { + * return Optional.of(createEvalJsonlRun.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { createEvalJsonlRun != null -> visitor.visitCreateEvalJsonlRun(createEvalJsonlRun) @@ -726,6 +764,15 @@ private constructor( 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(): DataSource = apply { if (validated) { return@apply @@ -1270,6 +1317,16 @@ private constructor( 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(): CreateEvalResponsesRunDataSource = apply { if (validated) { return@apply @@ -1338,6 +1395,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -1348,6 +1435,16 @@ private constructor( 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 @@ -1679,6 +1776,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -1868,6 +1975,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1964,6 +2081,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -2078,6 +2205,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -2321,6 +2458,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply @@ -3028,6 +3175,16 @@ private constructor( 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(): Responses = apply { if (validated) { return@apply @@ -3208,6 +3365,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -3275,6 +3442,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = inputMessages.accept(new InputMessages.Visitor>() { + * @Override + * public Optional visitTemplate(Template template) { + * return Optional.of(template.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { template != null -> visitor.visitTemplate(template) @@ -3284,6 +3481,16 @@ private constructor( 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(): InputMessages = apply { if (validated) { return@apply @@ -3618,6 +3825,16 @@ private constructor( 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(): Template = apply { if (validated) { return@apply @@ -3695,6 +3912,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerTemplate.accept(new InnerTemplate.Visitor>() { + * @Override + * public Optional visitChatMessage(ChatMessage chatMessage) { + * return Optional.of(chatMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatMessage != null -> visitor.visitChatMessage(chatMessage) @@ -3704,6 +3952,16 @@ private constructor( 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(): InnerTemplate = apply { if (validated) { return@apply @@ -4045,6 +4303,16 @@ private constructor( 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(): ChatMessage = apply { if (validated) { return@apply @@ -4364,6 +4632,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -4477,6 +4755,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using + * the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new + * variants from the API, unless [visitor] overrides + * [Visitor.unknown]. To handle variants not known to this version + * of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not + * overridden in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -4493,6 +4802,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -4979,6 +5298,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -5262,6 +5591,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -5443,6 +5782,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -5581,6 +5930,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -5827,6 +6186,16 @@ private constructor( 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(): ItemReference = apply { if (validated) { return@apply @@ -6429,6 +6798,16 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply @@ -6630,6 +7009,16 @@ private constructor( 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(): Text = apply { if (validated) { return@apply @@ -6807,6 +7196,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt index 7908c481f..175106920 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunCreateResponse.kt @@ -887,6 +887,14 @@ private constructor( 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(): RunCreateResponse = apply { if (validated) { return@apply @@ -983,6 +991,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSource.accept(new DataSource.Visitor>() { + * @Override + * public Optional visitJsonl(CreateEvalJsonlRunDataSource jsonl) { + * return Optional.of(jsonl.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { jsonl != null -> visitor.visitJsonl(jsonl) @@ -993,6 +1030,15 @@ private constructor( 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(): DataSource = apply { if (validated) { return@apply @@ -1502,6 +1548,16 @@ private constructor( 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(): Responses = apply { if (validated) { return@apply @@ -1574,6 +1630,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -1584,6 +1670,16 @@ private constructor( 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 @@ -1917,6 +2013,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -2106,6 +2212,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -2202,6 +2318,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -2316,6 +2442,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -2559,6 +2695,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply @@ -3268,6 +3414,16 @@ private constructor( 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(): InnerResponses = apply { if (validated) { return@apply @@ -3390,6 +3546,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = inputMessages.accept(new InputMessages.Visitor>() { + * @Override + * public Optional visitTemplate(Template template) { + * return Optional.of(template.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { template != null -> visitor.visitTemplate(template) @@ -3399,6 +3585,16 @@ private constructor( 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(): InputMessages = apply { if (validated) { return@apply @@ -3733,6 +3929,16 @@ private constructor( 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(): Template = apply { if (validated) { return@apply @@ -3810,6 +4016,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerTemplate.accept(new InnerTemplate.Visitor>() { + * @Override + * public Optional visitChatMessage(ChatMessage chatMessage) { + * return Optional.of(chatMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatMessage != null -> visitor.visitChatMessage(chatMessage) @@ -3819,6 +4056,16 @@ private constructor( 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(): InnerTemplate = apply { if (validated) { return@apply @@ -4160,6 +4407,16 @@ private constructor( 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(): ChatMessage = apply { if (validated) { return@apply @@ -4479,6 +4736,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -4592,6 +4859,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using + * the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new + * variants from the API, unless [visitor] overrides + * [Visitor.unknown]. To handle variants not known to this version + * of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not + * overridden in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -4608,6 +4906,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -5094,6 +5402,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -5377,6 +5695,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -5558,6 +5886,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -5696,6 +6034,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -5942,6 +6290,16 @@ private constructor( 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(): ItemReference = apply { if (validated) { return@apply @@ -6544,6 +6902,16 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply @@ -6745,6 +7113,16 @@ private constructor( 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(): Text = apply { if (validated) { return@apply @@ -6922,6 +7300,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -7293,6 +7680,15 @@ private constructor( 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(): PerModelUsage = apply { if (validated) { return@apply @@ -7555,6 +7951,15 @@ private constructor( 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(): PerTestingCriteriaResult = apply { if (validated) { return@apply @@ -7827,6 +8232,15 @@ private constructor( 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(): ResultCounts = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunDeleteResponse.kt index 061c3822e..cd2f1f3e6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunDeleteResponse.kt @@ -164,6 +164,14 @@ private constructor( 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(): RunDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListPageResponse.kt index 49d9a7584..021cd833d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListPageResponse.kt @@ -282,6 +282,14 @@ private constructor( 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(): RunListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListParams.kt index 1fa950c30..a6876f1a4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListParams.kt @@ -349,6 +349,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply @@ -495,6 +504,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt index 1bba7278a..11c9a0a4c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunListResponse.kt @@ -887,6 +887,14 @@ private constructor( 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(): RunListResponse = apply { if (validated) { return@apply @@ -983,6 +991,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSource.accept(new DataSource.Visitor>() { + * @Override + * public Optional visitJsonl(CreateEvalJsonlRunDataSource jsonl) { + * return Optional.of(jsonl.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { jsonl != null -> visitor.visitJsonl(jsonl) @@ -993,6 +1030,15 @@ private constructor( 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(): DataSource = apply { if (validated) { return@apply @@ -1502,6 +1548,16 @@ private constructor( 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(): Responses = apply { if (validated) { return@apply @@ -1574,6 +1630,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -1584,6 +1670,16 @@ private constructor( 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 @@ -1917,6 +2013,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -2106,6 +2212,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -2202,6 +2318,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -2316,6 +2442,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -2559,6 +2695,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply @@ -3268,6 +3414,16 @@ private constructor( 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(): InnerResponses = apply { if (validated) { return@apply @@ -3390,6 +3546,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = inputMessages.accept(new InputMessages.Visitor>() { + * @Override + * public Optional visitTemplate(Template template) { + * return Optional.of(template.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { template != null -> visitor.visitTemplate(template) @@ -3399,6 +3585,16 @@ private constructor( 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(): InputMessages = apply { if (validated) { return@apply @@ -3733,6 +3929,16 @@ private constructor( 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(): Template = apply { if (validated) { return@apply @@ -3810,6 +4016,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerTemplate.accept(new InnerTemplate.Visitor>() { + * @Override + * public Optional visitChatMessage(ChatMessage chatMessage) { + * return Optional.of(chatMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatMessage != null -> visitor.visitChatMessage(chatMessage) @@ -3819,6 +4056,16 @@ private constructor( 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(): InnerTemplate = apply { if (validated) { return@apply @@ -4160,6 +4407,16 @@ private constructor( 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(): ChatMessage = apply { if (validated) { return@apply @@ -4479,6 +4736,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -4592,6 +4859,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using + * the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new + * variants from the API, unless [visitor] overrides + * [Visitor.unknown]. To handle variants not known to this version + * of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not + * overridden in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -4608,6 +4906,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -5094,6 +5402,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -5377,6 +5695,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -5558,6 +5886,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -5696,6 +6034,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -5942,6 +6290,16 @@ private constructor( 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(): ItemReference = apply { if (validated) { return@apply @@ -6544,6 +6902,16 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply @@ -6745,6 +7113,16 @@ private constructor( 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(): Text = apply { if (validated) { return@apply @@ -6922,6 +7300,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -7293,6 +7680,15 @@ private constructor( 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(): PerModelUsage = apply { if (validated) { return@apply @@ -7555,6 +7951,15 @@ private constructor( 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(): PerTestingCriteriaResult = apply { if (validated) { return@apply @@ -7827,6 +8232,15 @@ private constructor( 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(): ResultCounts = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt index a0456b581..e2d659fce 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/RunRetrieveResponse.kt @@ -887,6 +887,14 @@ private constructor( 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(): RunRetrieveResponse = apply { if (validated) { return@apply @@ -983,6 +991,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = dataSource.accept(new DataSource.Visitor>() { + * @Override + * public Optional visitJsonl(CreateEvalJsonlRunDataSource jsonl) { + * return Optional.of(jsonl.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { jsonl != null -> visitor.visitJsonl(jsonl) @@ -993,6 +1030,15 @@ private constructor( 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(): DataSource = apply { if (validated) { return@apply @@ -1502,6 +1548,16 @@ private constructor( 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(): Responses = apply { if (validated) { return@apply @@ -1574,6 +1630,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = source.accept(new Source.Visitor>() { + * @Override + * public Optional visitFileContent(FileContent fileContent) { + * return Optional.of(fileContent.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { fileContent != null -> visitor.visitFileContent(fileContent) @@ -1584,6 +1670,16 @@ private constructor( 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 @@ -1917,6 +2013,16 @@ private constructor( 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(): FileContent = apply { if (validated) { return@apply @@ -2106,6 +2212,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -2202,6 +2318,16 @@ private constructor( 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(): Item = apply { if (validated) { return@apply @@ -2316,6 +2442,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -2559,6 +2695,16 @@ private constructor( 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(): FileId = apply { if (validated) { return@apply @@ -3268,6 +3414,16 @@ private constructor( 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(): InnerResponses = apply { if (validated) { return@apply @@ -3390,6 +3546,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the + * API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known + * to this version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = inputMessages.accept(new InputMessages.Visitor>() { + * @Override + * public Optional visitTemplate(Template template) { + * return Optional.of(template.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { template != null -> visitor.visitTemplate(template) @@ -3399,6 +3585,16 @@ private constructor( 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(): InputMessages = apply { if (validated) { return@apply @@ -3733,6 +3929,16 @@ private constructor( 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(): Template = apply { if (validated) { return@apply @@ -3810,6 +4016,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the + * given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from + * the API, unless [visitor] overrides [Visitor.unknown]. To handle variants + * not known to this version of the SDK gracefully, consider overriding + * [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = innerTemplate.accept(new InnerTemplate.Visitor>() { + * @Override + * public Optional visitChatMessage(ChatMessage chatMessage) { + * return Optional.of(chatMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden + * in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { chatMessage != null -> visitor.visitChatMessage(chatMessage) @@ -3819,6 +4056,16 @@ private constructor( 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(): InnerTemplate = apply { if (validated) { return@apply @@ -4160,6 +4407,16 @@ private constructor( 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(): ChatMessage = apply { if (validated) { return@apply @@ -4479,6 +4736,16 @@ private constructor( 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(): EvalItem = apply { if (validated) { return@apply @@ -4592,6 +4859,37 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using + * the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new + * variants from the API, unless [visitor] overrides + * [Visitor.unknown]. To handle variants not known to this version + * of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not + * overridden in [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -4608,6 +4906,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -5094,6 +5402,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -5377,6 +5695,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -5558,6 +5886,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -5696,6 +6034,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -5942,6 +6290,16 @@ private constructor( 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(): ItemReference = apply { if (validated) { return@apply @@ -6544,6 +6902,16 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply @@ -6745,6 +7113,16 @@ private constructor( 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(): Text = apply { if (validated) { return@apply @@ -6922,6 +7300,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -7293,6 +7680,15 @@ private constructor( 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(): PerModelUsage = apply { if (validated) { return@apply @@ -7555,6 +7951,15 @@ private constructor( 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(): PerTestingCriteriaResult = apply { if (validated) { return@apply @@ -7827,6 +8232,15 @@ private constructor( 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(): ResultCounts = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListPageResponse.kt index bbc42b78e..ca3eef1f9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListPageResponse.kt @@ -284,6 +284,14 @@ private constructor( 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(): OutputItemListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListParams.kt index 454272089..244ae33cc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListParams.kt @@ -372,6 +372,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply @@ -501,6 +510,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListResponse.kt index 04852007a..b83219e4f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemListResponse.kt @@ -478,6 +478,14 @@ private constructor( 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(): OutputItemListResponse = apply { if (validated) { return@apply @@ -585,6 +593,15 @@ private constructor( 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(): DatasourceItem = apply { if (validated) { return@apply @@ -878,6 +895,15 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -975,6 +1001,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -1528,6 +1564,15 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -1731,6 +1776,16 @@ private constructor( 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(): Input = apply { if (validated) { return@apply @@ -1913,6 +1968,16 @@ private constructor( 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(): Output = apply { if (validated) { return@apply @@ -2216,6 +2281,16 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemRetrieveResponse.kt index 9b99cb25b..6f496b67a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/evals/runs/outputitems/OutputItemRetrieveResponse.kt @@ -478,6 +478,14 @@ private constructor( 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(): OutputItemRetrieveResponse = apply { if (validated) { return@apply @@ -585,6 +593,15 @@ private constructor( 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(): DatasourceItem = apply { if (validated) { return@apply @@ -878,6 +895,15 @@ private constructor( 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(): Result = apply { if (validated) { return@apply @@ -975,6 +1001,16 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -1528,6 +1564,15 @@ private constructor( 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(): Sample = apply { if (validated) { return@apply @@ -1731,6 +1776,16 @@ private constructor( 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(): Input = apply { if (validated) { return@apply @@ -1913,6 +1968,16 @@ private constructor( 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(): Output = apply { if (validated) { return@apply @@ -2216,6 +2281,16 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt index 150d8a669..9f5bf9895 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileCreateParams.kt @@ -563,6 +563,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -755,6 +764,15 @@ private constructor( 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(): ExpiresAfter = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleted.kt index 9fd2a4d65..c7862d57d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileDeleted.kt @@ -187,6 +187,14 @@ private constructor( 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(): FileDeleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileListPageResponse.kt index c39e12d14..e9b1d86b6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileListPageResponse.kt @@ -265,6 +265,14 @@ private constructor( 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(): FileListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileListParams.kt index c04abe7cf..43c0504e4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileListParams.kt @@ -342,6 +342,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FileObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FileObject.kt index 927db21a2..47a31fa35 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FileObject.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FileObject.kt @@ -431,6 +431,14 @@ private constructor( 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(): FileObject = apply { if (validated) { return@apply @@ -604,6 +612,15 @@ private constructor( 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(): Purpose = apply { if (validated) { return@apply @@ -740,6 +757,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/files/FilePurpose.kt b/openai-java-core/src/main/kotlin/com/openai/models/files/FilePurpose.kt index 74449f5af..9dd0f42c3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/files/FilePurpose.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/files/FilePurpose.kt @@ -125,6 +125,14 @@ class FilePurpose @JsonCreator private constructor(private val value: JsonField< 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(): FilePurpose = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunParams.kt index f63d07d99..9b4aba1f1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunParams.kt @@ -529,6 +529,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -645,6 +654,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = grader.accept(new Grader.Visitor>() { + * @Override + * public Optional visitStringCheck(StringCheckGrader stringCheck) { + * return Optional.of(stringCheck.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { stringCheck != null -> visitor.visitStringCheck(stringCheck) @@ -657,6 +695,15 @@ private constructor( 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(): Grader = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunResponse.kt index f3226ed15..ab6bb52f3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderRunResponse.kt @@ -238,6 +238,14 @@ private constructor( 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(): GraderRunResponse = apply { if (validated) { return@apply @@ -612,6 +620,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1354,6 +1371,16 @@ private constructor( 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(): Errors = apply { if (validated) { return@apply @@ -1517,6 +1544,16 @@ private constructor( 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(): Scores = apply { if (validated) { return@apply @@ -1657,6 +1694,15 @@ private constructor( 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(): ModelGraderTokenUsagePerModel = apply { if (validated) { return@apply @@ -1758,6 +1804,15 @@ private constructor( 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(): SubRewards = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateParams.kt index b877def0b..889eb314c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateParams.kt @@ -403,6 +403,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -510,6 +519,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = grader.accept(new Grader.Visitor>() { + * @Override + * public Optional visitStringCheck(StringCheckGrader stringCheck) { + * return Optional.of(stringCheck.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { stringCheck != null -> visitor.visitStringCheck(stringCheck) @@ -522,6 +560,15 @@ private constructor( 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(): Grader = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateResponse.kt index 9cb597799..9f725f508 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/alpha/graders/GraderValidateResponse.kt @@ -146,6 +146,14 @@ private constructor( 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(): GraderValidateResponse = apply { if (validated) { return@apply @@ -235,6 +243,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = grader.accept(new Grader.Visitor>() { + * @Override + * public Optional visitStringCheck(StringCheckGrader stringCheck) { + * return Optional.of(stringCheck.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { stringCheck != null -> visitor.visitStringCheck(stringCheck) @@ -247,6 +284,15 @@ private constructor( 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(): Grader = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreatePageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreatePageResponse.kt index 50f581f1f..5373545d9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreatePageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreatePageResponse.kt @@ -272,6 +272,14 @@ private constructor( 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(): PermissionCreatePageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateParams.kt index 8f7b9f6ea..d07953c8a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateParams.kt @@ -415,6 +415,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateResponse.kt index e1b1a87f9..6c94fe102 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionCreateResponse.kt @@ -230,6 +230,14 @@ private constructor( 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(): PermissionCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionDeleteResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionDeleteResponse.kt index a2ff688ca..75c16cca1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionDeleteResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionDeleteResponse.kt @@ -195,6 +195,14 @@ private constructor( 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(): PermissionDeleteResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListPageResponse.kt index 33899dd60..7656ca588 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListPageResponse.kt @@ -272,6 +272,14 @@ private constructor( 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(): PermissionListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListParams.kt index 6da26132b..cbbb75b8a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListParams.kt @@ -346,6 +346,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListResponse.kt index e69caa0f4..14787610d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionListResponse.kt @@ -230,6 +230,14 @@ private constructor( 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(): PermissionListResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveParams.kt index 10b1f0e7e..9d2f2aa06 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveParams.kt @@ -347,6 +347,15 @@ private constructor( 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(): Order = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveResponse.kt index a020adda4..73b82927d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/checkpoints/permissions/PermissionRetrieveResponse.kt @@ -267,6 +267,14 @@ private constructor( 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(): PermissionRetrieveResponse = apply { if (validated) { return@apply @@ -528,6 +536,15 @@ private constructor( 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(): Data = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJob.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJob.kt index dbc107c16..38c6b38f6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJob.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJob.kt @@ -967,6 +967,14 @@ private constructor( 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(): FineTuningJob = apply { if (validated) { return@apply @@ -1228,6 +1236,15 @@ private constructor( 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(): Error = apply { if (validated) { return@apply @@ -1505,6 +1522,15 @@ private constructor( 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(): Hyperparameters = apply { if (validated) { return@apply @@ -1563,6 +1589,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = batchSize.accept(new BatchSize.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1572,6 +1628,16 @@ private constructor( 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(): BatchSize = apply { if (validated) { return@apply @@ -1746,6 +1812,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = learningRateMultiplier.accept(new LearningRateMultiplier.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1755,6 +1851,16 @@ private constructor( 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(): LearningRateMultiplier = apply { if (validated) { return@apply @@ -1933,6 +2039,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = nEpochs.accept(new NEpochs.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1942,6 +2078,16 @@ private constructor( 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(): NEpochs = apply { if (validated) { return@apply @@ -2226,6 +2372,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -2330,6 +2485,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -2599,6 +2763,15 @@ private constructor( 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(): Method = apply { if (validated) { return@apply @@ -2728,6 +2901,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobEvent.kt index ccf6ff05d..b2a4908d7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobEvent.kt @@ -314,6 +314,14 @@ private constructor( 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(): FineTuningJobEvent = apply { if (validated) { return@apply @@ -448,6 +456,15 @@ private constructor( 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(): Level = apply { if (validated) { return@apply @@ -574,6 +591,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegration.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegration.kt index eb7c29488..68a3bee09 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegration.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegration.kt @@ -263,6 +263,14 @@ private constructor( 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(): FineTuningJobWandbIntegration = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegrationObject.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegrationObject.kt index 27de8138a..486647234 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegrationObject.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/FineTuningJobWandbIntegrationObject.kt @@ -180,6 +180,14 @@ private constructor( 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(): FineTuningJobWandbIntegrationObject = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt index e75bf0aea..205445e5b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobCreateParams.kt @@ -1188,6 +1188,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1373,6 +1382,15 @@ private constructor( 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(): Model = apply { if (validated) { return@apply @@ -1633,6 +1651,15 @@ private constructor( 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(): Hyperparameters = apply { if (validated) { return@apply @@ -1691,6 +1718,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = batchSize.accept(new BatchSize.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1700,6 +1757,16 @@ private constructor( 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(): BatchSize = apply { if (validated) { return@apply @@ -1874,6 +1941,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = learningRateMultiplier.accept(new LearningRateMultiplier.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1883,6 +1980,16 @@ private constructor( 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(): LearningRateMultiplier = apply { if (validated) { return@apply @@ -2061,6 +2168,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = nEpochs.accept(new NEpochs.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -2070,6 +2207,16 @@ private constructor( 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(): NEpochs = apply { if (validated) { return@apply @@ -2396,6 +2543,15 @@ private constructor( 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(): Integration = apply { if (validated) { return@apply @@ -2692,6 +2848,16 @@ private constructor( 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(): Wandb = apply { if (validated) { return@apply @@ -2833,6 +2999,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -3102,6 +3277,15 @@ private constructor( 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(): Method = apply { if (validated) { return@apply @@ -3231,6 +3415,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListEventsPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListEventsPageResponse.kt index 37dbe99ed..929489d54 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListEventsPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListEventsPageResponse.kt @@ -207,6 +207,14 @@ private constructor( 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(): JobListEventsPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListPageResponse.kt index deada0104..f9c0217b7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/JobListPageResponse.kt @@ -207,6 +207,14 @@ private constructor( 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(): JobListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/CheckpointListPageResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/CheckpointListPageResponse.kt index 7bed8a97c..ba1af80a8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/CheckpointListPageResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/CheckpointListPageResponse.kt @@ -272,6 +272,14 @@ private constructor( 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(): CheckpointListPageResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/FineTuningJobCheckpoint.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/FineTuningJobCheckpoint.kt index cdc6962a9..b8037d42b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/FineTuningJobCheckpoint.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/jobs/checkpoints/FineTuningJobCheckpoint.kt @@ -360,6 +360,14 @@ private constructor( 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(): FineTuningJobCheckpoint = apply { if (validated) { return@apply @@ -723,6 +731,15 @@ private constructor( 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(): Metrics = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoHyperparameters.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoHyperparameters.kt index 25611ec96..fd7e0a6fe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoHyperparameters.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoHyperparameters.kt @@ -280,6 +280,14 @@ private constructor( 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(): DpoHyperparameters = apply { if (validated) { return@apply @@ -339,6 +347,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = batchSize.accept(new BatchSize.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -348,6 +385,15 @@ private constructor( 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(): BatchSize = apply { if (validated) { return@apply @@ -519,6 +565,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = beta.accept(new Beta.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -528,6 +603,15 @@ private constructor( 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(): Beta = apply { if (validated) { return@apply @@ -696,6 +780,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = learningRateMultiplier.accept(new LearningRateMultiplier.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -705,6 +818,15 @@ private constructor( 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(): LearningRateMultiplier = apply { if (validated) { return@apply @@ -879,6 +1001,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = nEpochs.accept(new NEpochs.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -888,6 +1039,15 @@ private constructor( 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(): NEpochs = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoMethod.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoMethod.kt index 859d9486a..118431ca4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoMethod.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/DpoMethod.kt @@ -123,6 +123,14 @@ private constructor( 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(): DpoMethod = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementHyperparameters.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementHyperparameters.kt index af0131200..8d5ea07d9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementHyperparameters.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementHyperparameters.kt @@ -427,6 +427,14 @@ private constructor( 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(): ReinforcementHyperparameters = apply { if (validated) { return@apply @@ -492,6 +500,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = batchSize.accept(new BatchSize.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -501,6 +538,15 @@ private constructor( 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(): BatchSize = apply { if (validated) { return@apply @@ -669,6 +715,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = computeMultiplier.accept(new ComputeMultiplier.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -678,6 +753,15 @@ private constructor( 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(): ComputeMultiplier = apply { if (validated) { return@apply @@ -848,6 +932,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = evalInterval.accept(new EvalInterval.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -857,6 +970,15 @@ private constructor( 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(): EvalInterval = apply { if (validated) { return@apply @@ -1026,6 +1148,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = evalSamples.accept(new EvalSamples.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1035,6 +1186,15 @@ private constructor( 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(): EvalSamples = apply { if (validated) { return@apply @@ -1207,6 +1367,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = learningRateMultiplier.accept(new LearningRateMultiplier.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1216,6 +1405,15 @@ private constructor( 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(): LearningRateMultiplier = apply { if (validated) { return@apply @@ -1390,6 +1588,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = nEpochs.accept(new NEpochs.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -1399,6 +1626,15 @@ private constructor( 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(): NEpochs = apply { if (validated) { return@apply @@ -1647,6 +1883,15 @@ private constructor( 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(): ReasoningEffort = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementMethod.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementMethod.kt index 289773161..41a3f3e4c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementMethod.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/ReinforcementMethod.kt @@ -205,6 +205,14 @@ private constructor( 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(): ReinforcementMethod = apply { if (validated) { return@apply @@ -298,6 +306,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = grader.accept(new Grader.Visitor>() { + * @Override + * public Optional visitStringCheck(StringCheckGrader stringCheck) { + * return Optional.of(stringCheck.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { stringCheck != null -> visitor.visitStringCheck(stringCheck) @@ -310,6 +347,15 @@ private constructor( 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(): Grader = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedHyperparameters.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedHyperparameters.kt index 15d28d9c5..24a4dbfb7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedHyperparameters.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedHyperparameters.kt @@ -241,6 +241,14 @@ private constructor( 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(): SupervisedHyperparameters = apply { if (validated) { return@apply @@ -298,6 +306,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = batchSize.accept(new BatchSize.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -307,6 +344,15 @@ private constructor( 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(): BatchSize = apply { if (validated) { return@apply @@ -478,6 +524,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = learningRateMultiplier.accept(new LearningRateMultiplier.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -487,6 +562,15 @@ private constructor( 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(): LearningRateMultiplier = apply { if (validated) { return@apply @@ -661,6 +745,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = nEpochs.accept(new NEpochs.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -670,6 +783,15 @@ private constructor( 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(): NEpochs = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedMethod.kt b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedMethod.kt index c459677ec..2c88cbd6f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedMethod.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/finetuning/methods/SupervisedMethod.kt @@ -124,6 +124,14 @@ private constructor( 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(): SupervisedMethod = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt index 885f678b0..5f8e99b73 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/EvalContentItem.kt @@ -85,6 +85,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = evalContentItem.accept(new EvalContentItem.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -97,6 +126,14 @@ private constructor( 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(): EvalContentItem = apply { if (validated) { return@apply @@ -448,6 +485,15 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -687,6 +733,15 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt index b090130b6..e61f5c4dc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/LabelModelGrader.kt @@ -359,6 +359,14 @@ private constructor( 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(): LabelModelGrader = apply { if (validated) { return@apply @@ -618,6 +626,15 @@ private constructor( 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(): Input = apply { if (validated) { return@apply @@ -726,6 +743,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -740,6 +787,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1143,6 +1200,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -1392,6 +1459,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -1552,6 +1629,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1674,6 +1761,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/MultiGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/MultiGrader.kt index c95c690a3..ae80f0bba 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/MultiGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/MultiGrader.kt @@ -275,6 +275,14 @@ private constructor( 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(): MultiGrader = apply { if (validated) { return@apply @@ -385,6 +393,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = graders.accept(new Graders.Visitor>() { + * @Override + * public Optional visitStringCheckGrader(StringCheckGrader stringCheckGrader) { + * return Optional.of(stringCheckGrader.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { stringCheckGrader != null -> visitor.visitStringCheckGrader(stringCheckGrader) @@ -398,6 +435,15 @@ private constructor( 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(): Graders = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/PythonGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/PythonGrader.kt index 20ae48ae4..232674b1f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/PythonGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/PythonGrader.kt @@ -228,6 +228,14 @@ private constructor( 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(): PythonGrader = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt index 8b0165922..8fb6c2a95 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/ScoreModelGrader.kt @@ -352,6 +352,14 @@ private constructor( 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(): ScoreModelGrader = apply { if (validated) { return@apply @@ -611,6 +619,15 @@ private constructor( 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(): Input = apply { if (validated) { return@apply @@ -719,6 +736,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = content.accept(new Content.Visitor>() { + * @Override + * public Optional visitTextInput(String textInput) { + * return Optional.of(textInput.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { textInput != null -> visitor.visitTextInput(textInput) @@ -733,6 +780,16 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -1136,6 +1193,16 @@ private constructor( 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(): OutputText = apply { if (validated) { return@apply @@ -1385,6 +1452,16 @@ private constructor( 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(): InputImage = apply { if (validated) { return@apply @@ -1545,6 +1622,16 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1667,6 +1754,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -2055,6 +2152,15 @@ private constructor( 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(): SamplingParams = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/StringCheckGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/StringCheckGrader.kt index 6b19bbf89..a9782bd99 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/StringCheckGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/StringCheckGrader.kt @@ -271,6 +271,14 @@ private constructor( 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(): StringCheckGrader = apply { if (validated) { return@apply @@ -411,6 +419,15 @@ private constructor( 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(): Operation = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/TextSimilarityGrader.kt b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/TextSimilarityGrader.kt index 082eda2b2..1688175bc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/TextSimilarityGrader.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/graders/gradermodels/TextSimilarityGrader.kt @@ -278,6 +278,14 @@ private constructor( 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(): TextSimilarityGrader = apply { if (validated) { return@apply @@ -465,6 +473,15 @@ private constructor( 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(): EvaluationMetric = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/Image.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/Image.kt index e3192cbc3..7b3268b0a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/Image.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/Image.kt @@ -189,6 +189,14 @@ private constructor( 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(): Image = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt index 67e140900..28792f815 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageCreateVariationParams.kt @@ -793,6 +793,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -935,6 +944,15 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply @@ -1067,6 +1085,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditCompletedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditCompletedEvent.kt index ebc631d0d..c1417fac4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditCompletedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditCompletedEvent.kt @@ -385,6 +385,14 @@ private constructor( 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(): ImageEditCompletedEvent = apply { if (validated) { return@apply @@ -525,6 +533,15 @@ private constructor( 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(): Background = apply { if (validated) { return@apply @@ -660,6 +677,15 @@ private constructor( 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(): OutputFormat = apply { if (validated) { return@apply @@ -798,6 +824,15 @@ private constructor( 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(): Quality = apply { if (validated) { return@apply @@ -936,6 +971,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply @@ -1217,6 +1261,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply @@ -1418,6 +1471,16 @@ private constructor( 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(): InputTokensDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt index c4b54c3a2..e5834d8a9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditParams.kt @@ -46,9 +46,9 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each image - * should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 images. - * `chatgpt-image-latest` follows the same input constraints as GPT image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + * `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image should be a `png`, `webp`, + * or `jpg` file less than 50MB. You can provide up to 16 images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file less * than 4MB. @@ -69,9 +69,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter is - * only supported for the GPT image models. Must be one of `transparent`, `opaque` or `auto` - * (default value). When `auto` is used, the model will automatically determine the best - * background for the image. + * only supported for GPT image models that support transparent backgrounds. Must be one of + * `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model will + * automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. Requests + * with `background` set to `transparent` will return an error for these models; use `opaque` or + * `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -104,7 +108,9 @@ private constructor( fun mask(): Optional = body.mask() /** - * The model to use for image generation. Defaults to `gpt-image-1.5`. + * The model to use for image generation. One of `dall-e-2` or a GPT image model (`gpt-image-1`, + * `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, `gpt-image-2-2026-04-21`, or + * `chatgpt-image-latest`). Defaults to `gpt-image-1.5`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -170,9 +176,15 @@ private constructor( fun responseFormat(): Optional = body.responseFormat() /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, and one of - * `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary + * resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + * must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. + * Resolutions above `2560x1440` are experimental, and the maximum supported resolution is + * `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. + * The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image + * models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one + * of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, + * or `1024x1792`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -347,9 +359,9 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each - * image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 - * images. `chatgpt-image-latest` follows the same input constraints as GPT image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image should + * be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file less * than 4MB. @@ -370,9 +382,9 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each - * image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 - * images. `chatgpt-image-latest` follows the same input constraints as GPT image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image should + * be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file less * than 4MB. @@ -382,9 +394,9 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each - * image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 - * images. `chatgpt-image-latest` follows the same input constraints as GPT image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image should + * be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file less * than 4MB. @@ -412,9 +424,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter - * is only supported for the GPT image models. Must be one of `transparent`, `opaque` or - * `auto` (default value). When `auto` is used, the model will automatically determine the - * best background for the image. + * is only supported for GPT image models that support transparent backgrounds. Must be one + * of `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model + * will automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. + * Requests with `background` set to `transparent` will return an error for these models; + * use `opaque` or `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -493,7 +509,11 @@ private constructor( */ fun mask(path: Path) = apply { body.mask(path) } - /** The model to use for image generation. Defaults to `gpt-image-1.5`. */ + /** + * The model to use for image generation. One of `dall-e-2` or a GPT image model + * (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + * `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to `gpt-image-1.5`. + */ fun model(model: ImageModel?) = apply { body.model(model) } /** Alias for calling [Builder.model] with `model.orElse(null)`. */ @@ -663,9 +683,15 @@ private constructor( } /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, and one of - * `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, + * arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. + * Width and height must both be divisible by 16 and the requested aspect ratio must be + * between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + * supported resolution is `3840x2160`. The requested size must also satisfy the model's + * current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and + * `1024x1536` are supported by the GPT image models; `auto` is supported for models that + * allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. + * For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`. */ fun size(size: Size?) = apply { body.size(size) } @@ -680,6 +706,14 @@ private constructor( */ fun size(size: MultipartField) = apply { body.size(size) } + /** + * Sets [size] to an arbitrary [String]. + * + * You should usually call [size] with a well-typed [Size] constant instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(value: String) = apply { body.size(value) } + /** * A unique identifier representing your end-user, which can help OpenAI to monitor and * detect abuse. @@ -874,9 +908,9 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each - * image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 - * images. `chatgpt-image-latest` follows the same input constraints as GPT image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image should + * be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file less * than 4MB. @@ -897,9 +931,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter - * is only supported for the GPT image models. Must be one of `transparent`, `opaque` or - * `auto` (default value). When `auto` is used, the model will automatically determine the - * best background for the image. + * is only supported for GPT image models that support transparent backgrounds. Must be one + * of `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model + * will automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. + * Requests with `background` set to `transparent` will return an error for these models; + * use `opaque` or `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -933,7 +971,9 @@ private constructor( fun mask(): Optional = mask.value.getOptional("mask") /** - * The model to use for image generation. Defaults to `gpt-image-1.5`. + * The model to use for image generation. One of `dall-e-2` or a GPT image model + * (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + * `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to `gpt-image-1.5`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1002,9 +1042,15 @@ private constructor( responseFormat.value.getOptional("response_format") /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, and one of - * `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, + * arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. + * Width and height must both be divisible by 16 and the requested aspect ratio must be + * between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + * supported resolution is `3840x2160`. The requested size must also satisfy the model's + * current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and + * `1024x1536` are supported by the GPT image models; `auto` is supported for models that + * allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. + * For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1205,10 +1251,10 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), - * each image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide - * up to 16 images. `chatgpt-image-latest` follows the same input constraints as GPT - * image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + * should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 + * images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file * less than 4MB. @@ -1236,10 +1282,10 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), - * each image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide - * up to 16 images. `chatgpt-image-latest` follows the same input constraints as GPT - * image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + * should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 + * images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file * less than 4MB. @@ -1249,10 +1295,10 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), - * each image should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide - * up to 16 images. `chatgpt-image-latest` follows the same input constraints as GPT - * image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, + * `gpt-image-2`, `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image + * should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 + * images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file * less than 4MB. @@ -1287,9 +1333,14 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This - * parameter is only supported for the GPT image models. Must be one of `transparent`, - * `opaque` or `auto` (default value). When `auto` is used, the model will automatically - * determine the best background for the image. + * parameter is only supported for GPT image models that support transparent + * backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). When + * `auto` is used, the model will automatically determine the best background for the + * image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. + * Requests with `background` set to `transparent` will return an error for these + * models; use `opaque` or `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be * set to either `png` (default value) or `webp`. @@ -1373,7 +1424,11 @@ private constructor( .build() ) - /** The model to use for image generation. Defaults to `gpt-image-1.5`. */ + /** + * The model to use for image generation. One of `dall-e-2` or a GPT image model + * (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + * `gpt-image-2-2026-04-21`, or `chatgpt-image-latest`). Defaults to `gpt-image-1.5`. + */ fun model(model: ImageModel?) = model(MultipartField.of(model)) /** Alias for calling [Builder.model] with `model.orElse(null)`. */ @@ -1551,9 +1606,16 @@ private constructor( } /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` - * (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - * models, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, + * arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example + * `1536x864`. Width and height must both be divisible by 16 and the requested aspect + * ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, + * and the maximum supported resolution is `3840x2160`. The requested size must also + * satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, + * `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is + * supported for models that allow automatic sizing. For `dall-e-2`, use one of + * `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + * `1792x1024`, or `1024x1792`. */ fun size(size: Size?) = size(MultipartField.of(size)) @@ -1569,6 +1631,14 @@ private constructor( */ fun size(size: MultipartField) = apply { this.size = size } + /** + * Sets [size] to an arbitrary [String]. + * + * You should usually call [size] with a well-typed [Size] constant instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(value: String) = size(Size.of(value)) + /** * A unique identifier representing your end-user, which can help OpenAI to monitor and * detect abuse. @@ -1639,6 +1709,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1656,7 +1735,7 @@ private constructor( partialImages() quality().ifPresent { it.validate() } responseFormat().ifPresent { it.validate() } - size().ifPresent { it.validate() } + size() user() validated = true } @@ -1721,9 +1800,9 @@ private constructor( /** * The image(s) to edit. Must be a supported image file or an array of images. * - * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, and `gpt-image-1.5`), each image - * should be a `png`, `webp`, or `jpg` file less than 50MB. You can provide up to 16 images. - * `chatgpt-image-latest` follows the same input constraints as GPT image models. + * For the GPT image models (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, + * `gpt-image-2-2026-04-21`, and `chatgpt-image-latest`), each image should be a `png`, `webp`, + * or `jpg` file less than 50MB. You can provide up to 16 images. * * For `dall-e-2`, you can only provide one image, and it should be a square `png` file less * than 4MB. @@ -1750,6 +1829,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = image.accept(new Image.Visitor>() { + * @Override + * public Optional visitInputStream(InputStream inputStream) { + * return Optional.of(inputStream.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { inputStream != null -> visitor.visitInputStream(inputStream) @@ -1759,6 +1867,15 @@ private constructor( 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(): Image = apply { if (validated) { return@apply @@ -1853,9 +1970,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter is - * only supported for the GPT image models. Must be one of `transparent`, `opaque` or `auto` - * (default value). When `auto` is used, the model will automatically determine the best - * background for the image. + * only supported for GPT image models that support transparent backgrounds. Must be one of + * `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model will + * automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. Requests + * with `background` set to `transparent` will return an error for these models; use `opaque` or + * `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -1955,6 +2076,15 @@ private constructor( 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(): Background = apply { if (validated) { return@apply @@ -2090,6 +2220,15 @@ private constructor( 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(): InputFidelity = apply { if (validated) { return@apply @@ -2228,6 +2367,15 @@ private constructor( 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(): OutputFormat = apply { if (validated) { return@apply @@ -2372,6 +2520,15 @@ private constructor( 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(): Quality = apply { if (validated) { return@apply @@ -2507,6 +2664,15 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply @@ -2546,9 +2712,15 @@ private constructor( } /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, and one of - * `256x256`, `512x512`, or `1024x1024` for `dall-e-2`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary + * resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + * must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. + * Resolutions above `2560x1440` are experimental, and the maximum supported resolution is + * `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. + * The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image + * models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one + * of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, + * or `1024x1792`. */ class Size @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2661,6 +2833,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditPartialImageEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditPartialImageEvent.kt index 03f9a4b00..43dc1202e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditPartialImageEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditPartialImageEvent.kt @@ -394,6 +394,14 @@ private constructor( 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(): ImageEditPartialImageEvent = apply { if (validated) { return@apply @@ -534,6 +542,15 @@ private constructor( 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(): Background = apply { if (validated) { return@apply @@ -669,6 +686,15 @@ private constructor( 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(): OutputFormat = apply { if (validated) { return@apply @@ -807,6 +833,15 @@ private constructor( 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(): Quality = apply { if (validated) { return@apply @@ -945,6 +980,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditStreamEvent.kt index 50b6ed4f0..a8301534e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageEditStreamEvent.kt @@ -46,6 +46,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = imageEditStreamEvent.accept(new ImageEditStreamEvent.Visitor>() { + * @Override + * public Optional visitPartialImage(ImageEditPartialImageEvent partialImage) { + * return Optional.of(partialImage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { partialImage != null -> visitor.visitPartialImage(partialImage) @@ -55,6 +84,14 @@ private constructor( 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(): ImageEditStreamEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenCompletedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenCompletedEvent.kt index cc119f3ff..2de70515a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenCompletedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenCompletedEvent.kt @@ -385,6 +385,14 @@ private constructor( 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(): ImageGenCompletedEvent = apply { if (validated) { return@apply @@ -525,6 +533,15 @@ private constructor( 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(): Background = apply { if (validated) { return@apply @@ -660,6 +677,15 @@ private constructor( 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(): OutputFormat = apply { if (validated) { return@apply @@ -798,6 +824,15 @@ private constructor( 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(): Quality = apply { if (validated) { return@apply @@ -936,6 +971,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply @@ -1217,6 +1261,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply @@ -1418,6 +1471,16 @@ private constructor( 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(): InputTokensDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenPartialImageEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenPartialImageEvent.kt index 7ea2497fb..363f770a0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenPartialImageEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenPartialImageEvent.kt @@ -394,6 +394,14 @@ private constructor( 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(): ImageGenPartialImageEvent = apply { if (validated) { return@apply @@ -534,6 +542,15 @@ private constructor( 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(): Background = apply { if (validated) { return@apply @@ -669,6 +686,15 @@ private constructor( 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(): OutputFormat = apply { if (validated) { return@apply @@ -807,6 +833,15 @@ private constructor( 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(): Quality = apply { if (validated) { return@apply @@ -945,6 +980,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenStreamEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenStreamEvent.kt index c456ba9e3..d47e47e23 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenStreamEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenStreamEvent.kt @@ -50,6 +50,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = imageGenStreamEvent.accept(new ImageGenStreamEvent.Visitor>() { + * @Override + * public Optional visitGenerationPartialImage(ImageGenPartialImageEvent generationPartialImage) { + * return Optional.of(generationPartialImage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { generationPartialImage != null -> @@ -60,6 +89,14 @@ private constructor( 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(): ImageGenStreamEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt index ad39d5f0a..3069756e2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageGenerateParams.kt @@ -42,9 +42,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter is - * only supported for the GPT image models. Must be one of `transparent`, `opaque` or `auto` - * (default value). When `auto` is used, the model will automatically determine the best - * background for the image. + * only supported for GPT image models that support transparent backgrounds. Must be one of + * `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model will + * automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. Requests + * with `background` set to `transparent` will return an error for these models; use `opaque` or + * `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -56,8 +60,9 @@ private constructor( /** * The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image model - * (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless a - * parameter specific to the GPT image models is used. + * (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, or + * `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific to the GPT + * image models is used. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -137,10 +142,15 @@ private constructor( fun responseFormat(): Optional = body.responseFormat() /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, one of `256x256`, - * `512x512`, or `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, or `1024x1792` - * for `dall-e-3`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary + * resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + * must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. + * Resolutions above `2560x1440` are experimental, and the maximum supported resolution is + * `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. + * The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image + * models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one + * of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, + * or `1024x1792`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -327,9 +337,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter - * is only supported for the GPT image models. Must be one of `transparent`, `opaque` or - * `auto` (default value). When `auto` is used, the model will automatically determine the - * best background for the image. + * is only supported for GPT image models that support transparent backgrounds. Must be one + * of `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model + * will automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. + * Requests with `background` set to `transparent` will return an error for these models; + * use `opaque` or `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -350,8 +364,9 @@ private constructor( /** * The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image - * model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless - * a parameter specific to the GPT image models is used. + * model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, or + * `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific to the GPT + * image models is used. */ fun model(model: ImageModel?) = apply { body.model(model) } @@ -546,10 +561,15 @@ private constructor( } /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, one of - * `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, - * or `1024x1792` for `dall-e-3`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, + * arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. + * Width and height must both be divisible by 16 and the requested aspect ratio must be + * between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + * supported resolution is `3840x2160`. The requested size must also satisfy the model's + * current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and + * `1024x1536` are supported by the GPT image models; `auto` is supported for models that + * allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. + * For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`. */ fun size(size: Size?) = apply { body.size(size) } @@ -564,6 +584,14 @@ private constructor( */ fun size(size: JsonField) = apply { body.size(size) } + /** + * Sets [size] to an arbitrary [String]. + * + * You should usually call [size] with a well-typed [Size] constant instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(value: String) = apply { body.size(value) } + /** * The style of the generated images. This parameter is only supported for `dall-e-3`. Must * be one of `vivid` or `natural`. Vivid causes the model to lean towards generating @@ -815,9 +843,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter - * is only supported for the GPT image models. Must be one of `transparent`, `opaque` or - * `auto` (default value). When `auto` is used, the model will automatically determine the - * best background for the image. + * is only supported for GPT image models that support transparent backgrounds. Must be one + * of `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model + * will automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. + * Requests with `background` set to `transparent` will return an error for these models; + * use `opaque` or `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -829,8 +861,9 @@ private constructor( /** * The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image - * model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` unless - * a parameter specific to the GPT image models is used. + * model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, or + * `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific to the GPT + * image models is used. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -912,10 +945,15 @@ private constructor( responseFormat.getOptional("response_format") /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, one of - * `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, - * or `1024x1792` for `dall-e-3`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, + * arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. + * Width and height must both be divisible by 16 and the requested aspect ratio must be + * between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum + * supported resolution is `3840x2160`. The requested size must also satisfy the model's + * current pixel and edge limits. The standard sizes `1024x1024`, `1536x1024`, and + * `1024x1536` are supported by the GPT image models; `auto` is supported for models that + * allow automatic sizing. For `dall-e-2`, use one of `256x256`, `512x512`, or `1024x1024`. + * For `dall-e-3`, use one of `1024x1024`, `1792x1024`, or `1024x1792`. * * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1129,9 +1167,14 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This - * parameter is only supported for the GPT image models. Must be one of `transparent`, - * `opaque` or `auto` (default value). When `auto` is used, the model will automatically - * determine the best background for the image. + * parameter is only supported for GPT image models that support transparent + * backgrounds. Must be one of `transparent`, `opaque`, or `auto` (default value). When + * `auto` is used, the model will automatically determine the best background for the + * image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. + * Requests with `background` set to `transparent` will return an error for these + * models; use `opaque` or `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be * set to either `png` (default value) or `webp`. @@ -1154,8 +1197,9 @@ private constructor( /** * The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or a GPT image - * model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`). Defaults to `dall-e-2` - * unless a parameter specific to the GPT image models is used. + * model (`gpt-image-1`, `gpt-image-1-mini`, `gpt-image-1.5`, `gpt-image-2`, or + * `gpt-image-2-2026-04-21`). Defaults to `dall-e-2` unless a parameter specific to the + * GPT image models is used. */ fun model(model: ImageModel?) = model(JsonField.ofNullable(model)) @@ -1360,10 +1404,16 @@ private constructor( } /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` - * (landscape), `1024x1536` (portrait), or `auto` (default value) for the GPT image - * models, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and one of - * `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, + * arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for example + * `1536x864`. Width and height must both be divisible by 16 and the requested aspect + * ratio must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, + * and the maximum supported resolution is `3840x2160`. The requested size must also + * satisfy the model's current pixel and edge limits. The standard sizes `1024x1024`, + * `1536x1024`, and `1024x1536` are supported by the GPT image models; `auto` is + * supported for models that allow automatic sizing. For `dall-e-2`, use one of + * `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, + * `1792x1024`, or `1024x1792`. */ fun size(size: Size?) = size(JsonField.ofNullable(size)) @@ -1379,6 +1429,14 @@ private constructor( */ fun size(size: JsonField) = apply { this.size = size } + /** + * Sets [size] to an arbitrary [String]. + * + * You should usually call [size] with a well-typed [Size] constant instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(value: String) = size(Size.of(value)) + /** * The style of the generated images. This parameter is only supported for `dall-e-3`. * Must be one of `vivid` or `natural`. Vivid causes the model to lean towards @@ -1467,6 +1525,15 @@ private constructor( 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(): Body = apply { if (validated) { return@apply @@ -1482,7 +1549,7 @@ private constructor( partialImages() quality().ifPresent { it.validate() } responseFormat().ifPresent { it.validate() } - size().ifPresent { it.validate() } + size() style().ifPresent { it.validate() } user() validated = true @@ -1514,7 +1581,7 @@ private constructor( (if (partialImages.asKnown().isPresent) 1 else 0) + (quality.asKnown().getOrNull()?.validity() ?: 0) + (responseFormat.asKnown().getOrNull()?.validity() ?: 0) + - (size.asKnown().getOrNull()?.validity() ?: 0) + + (if (size.asKnown().isPresent) 1 else 0) + (style.asKnown().getOrNull()?.validity() ?: 0) + (if (user.asKnown().isPresent) 1 else 0) @@ -1567,9 +1634,13 @@ private constructor( /** * Allows to set transparency for the background of the generated image(s). This parameter is - * only supported for the GPT image models. Must be one of `transparent`, `opaque` or `auto` - * (default value). When `auto` is used, the model will automatically determine the best - * background for the image. + * only supported for GPT image models that support transparent backgrounds. Must be one of + * `transparent`, `opaque`, or `auto` (default value). When `auto` is used, the model will + * automatically determine the best background for the image. + * + * `gpt-image-2` and `gpt-image-2-2026-04-21` do not support transparent backgrounds. Requests + * with `background` set to `transparent` will return an error for these models; use `opaque` or + * `auto` instead. * * If `transparent`, the output format needs to support transparency, so it should be set to * either `png` (default value) or `webp`. @@ -1669,6 +1740,15 @@ private constructor( 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(): Background = apply { if (validated) { return@apply @@ -1800,6 +1880,15 @@ private constructor( 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(): Moderation = apply { if (validated) { return@apply @@ -1938,6 +2027,15 @@ private constructor( 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(): OutputFormat = apply { if (validated) { return@apply @@ -2094,6 +2192,15 @@ private constructor( 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(): Quality = apply { if (validated) { return@apply @@ -2229,6 +2336,15 @@ private constructor( 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(): ResponseFormat = apply { if (validated) { return@apply @@ -2268,10 +2384,15 @@ private constructor( } /** - * The size of the generated images. Must be one of `1024x1024`, `1536x1024` (landscape), - * `1024x1536` (portrait), or `auto` (default value) for the GPT image models, one of `256x256`, - * `512x512`, or `1024x1024` for `dall-e-2`, and one of `1024x1024`, `1792x1024`, or `1024x1792` - * for `dall-e-3`. + * The size of the generated images. For `gpt-image-2` and `gpt-image-2-2026-04-21`, arbitrary + * resolutions are supported as `WIDTHxHEIGHT` strings, for example `1536x864`. Width and height + * must both be divisible by 16 and the requested aspect ratio must be between 1:3 and 3:1. + * Resolutions above `2560x1440` are experimental, and the maximum supported resolution is + * `3840x2160`. The requested size must also satisfy the model's current pixel and edge limits. + * The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the GPT image + * models; `auto` is supported for models that allow automatic sizing. For `dall-e-2`, use one + * of `256x256`, `512x512`, or `1024x1024`. For `dall-e-3`, use one of `1024x1024`, `1792x1024`, + * or `1024x1792`. */ class Size @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2396,6 +2517,15 @@ private constructor( 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(): Size = apply { if (validated) { return@apply @@ -2527,6 +2657,15 @@ private constructor( 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(): Style = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageModel.kt index f94c0c4d0..b4603b6d1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/images/ImageModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/images/ImageModel.kt @@ -20,26 +20,35 @@ class ImageModel @JsonCreator private constructor(private val value: JsonField Value.GPT_IMAGE_1 + GPT_IMAGE_1_MINI -> Value.GPT_IMAGE_1_MINI + GPT_IMAGE_2 -> Value.GPT_IMAGE_2 + GPT_IMAGE_2_2026_04_21 -> Value.GPT_IMAGE_2_2026_04_21 GPT_IMAGE_1_5 -> Value.GPT_IMAGE_1_5 + CHATGPT_IMAGE_LATEST -> Value.CHATGPT_IMAGE_LATEST DALL_E_2 -> Value.DALL_E_2 DALL_E_3 -> Value.DALL_E_3 - GPT_IMAGE_1 -> Value.GPT_IMAGE_1 - GPT_IMAGE_1_MINI -> Value.GPT_IMAGE_1_MINI else -> Value._UNKNOWN } @@ -88,11 +103,14 @@ class ImageModel @JsonCreator private constructor(private val value: JsonField Known.GPT_IMAGE_1 + GPT_IMAGE_1_MINI -> Known.GPT_IMAGE_1_MINI + GPT_IMAGE_2 -> Known.GPT_IMAGE_2 + GPT_IMAGE_2_2026_04_21 -> Known.GPT_IMAGE_2_2026_04_21 GPT_IMAGE_1_5 -> Known.GPT_IMAGE_1_5 + CHATGPT_IMAGE_LATEST -> Known.CHATGPT_IMAGE_LATEST DALL_E_2 -> Known.DALL_E_2 DALL_E_3 -> Known.DALL_E_3 - GPT_IMAGE_1 -> Known.GPT_IMAGE_1 - GPT_IMAGE_1_MINI -> Known.GPT_IMAGE_1_MINI else -> throw OpenAIInvalidDataException("Unknown ImageModel: $value") } @@ -110,6 +128,14 @@ class ImageModel @JsonCreator private constructor(private val value: JsonField = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = input.accept(new Input.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -599,6 +637,15 @@ private constructor( 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(): Input = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateResponse.kt index 409009c10..d64c32ce4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationCreateResponse.kt @@ -217,6 +217,14 @@ private constructor( 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(): ModerationCreateResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationImageUrlInput.kt b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationImageUrlInput.kt index 77ed3ac4c..080bf0716 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationImageUrlInput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationImageUrlInput.kt @@ -165,6 +165,14 @@ private constructor( 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(): ModerationImageUrlInput = apply { if (validated) { return@apply @@ -311,6 +319,15 @@ private constructor( 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(): ImageUrl = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationModel.kt b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationModel.kt index 20ed335b2..8b30ab941 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationModel.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationModel.kt @@ -107,6 +107,14 @@ class ModerationModel @JsonCreator private constructor(private val value: JsonFi 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(): ModerationModel = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationMultiModalInput.kt b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationMultiModalInput.kt index 08eb90d15..efa3f9cb8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationMultiModalInput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationMultiModalInput.kt @@ -46,6 +46,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = moderationMultiModalInput.accept(new ModerationMultiModalInput.Visitor>() { + * @Override + * public Optional visitImageUrl(ModerationImageUrlInput imageUrl) { + * return Optional.of(imageUrl.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { imageUrl != null -> visitor.visitImageUrl(imageUrl) @@ -55,6 +84,14 @@ private constructor( 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(): ModerationMultiModalInput = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationTextInput.kt b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationTextInput.kt index 12738958f..d91bdf1fe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationTextInput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/moderations/ModerationTextInput.kt @@ -163,6 +163,14 @@ private constructor( 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(): ModerationTextInput = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/AudioTranscription.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/AudioTranscription.kt index 7e6dfe950..ae575fd8e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/AudioTranscription.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/AudioTranscription.kt @@ -206,6 +206,14 @@ private constructor( 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(): AudioTranscription = apply { if (validated) { return@apply @@ -348,6 +356,15 @@ private constructor( 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(): Model = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationCreatedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationCreatedEvent.kt index 131eccae4..d4323bec6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationCreatedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationCreatedEvent.kt @@ -206,6 +206,14 @@ private constructor( 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(): ConversationCreatedEvent = apply { if (validated) { return@apply @@ -371,6 +379,15 @@ private constructor( 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(): Conversation = apply { if (validated) { return@apply @@ -486,6 +503,16 @@ private constructor( 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(): Object = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItem.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItem.kt index eddd6e5da..e91ca594e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItem.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItem.kt @@ -145,6 +145,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = conversationItem.accept(new ConversationItem.Visitor>() { + * @Override + * public Optional visitRealtimeConversationItemSystemMessage(RealtimeConversationItemSystemMessage realtimeConversationItemSystemMessage) { + * return Optional.of(realtimeConversationItemSystemMessage.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { realtimeConversationItemSystemMessage != null -> @@ -170,6 +199,14 @@ private constructor( 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(): ConversationItem = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemAdded.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemAdded.kt index 6ded19089..9bf74701b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemAdded.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemAdded.kt @@ -362,6 +362,14 @@ private constructor( 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(): ConversationItemAdded = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreateEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreateEvent.kt index 3e065c39f..8116ae624 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreateEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreateEvent.kt @@ -360,6 +360,14 @@ private constructor( 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(): ConversationItemCreateEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreatedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreatedEvent.kt index d03efbe7c..b73ae0532 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreatedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemCreatedEvent.kt @@ -358,6 +358,14 @@ private constructor( 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(): ConversationItemCreatedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeleteEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeleteEvent.kt index a52e9d5f2..8047a9bdb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeleteEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeleteEvent.kt @@ -199,6 +199,14 @@ private constructor( 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(): ConversationItemDeleteEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeletedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeletedEvent.kt index 7f501da3f..e9c715313 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeletedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDeletedEvent.kt @@ -200,6 +200,14 @@ private constructor( 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(): ConversationItemDeletedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDone.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDone.kt index feb9ac0af..a51286cf0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDone.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemDone.kt @@ -354,6 +354,14 @@ private constructor( 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(): ConversationItemDone = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionCompletedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionCompletedEvent.kt index 9cbfd9a8b..2c589e9a2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionCompletedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionCompletedEvent.kt @@ -408,6 +408,14 @@ private constructor( 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(): ConversationItemInputAudioTranscriptionCompletedEvent = apply { if (validated) { return@apply @@ -488,6 +496,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = usage.accept(new Usage.Visitor>() { + * @Override + * public Optional visitTranscriptTextUsageTokens(TranscriptTextUsageTokens transcriptTextUsageTokens) { + * return Optional.of(transcriptTextUsageTokens.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { transcriptTextUsageTokens != null -> @@ -499,6 +536,15 @@ private constructor( 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(): Usage = apply { if (validated) { return@apply @@ -958,6 +1004,16 @@ private constructor( 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(): TranscriptTextUsageTokens = apply { if (validated) { return@apply @@ -1152,6 +1208,16 @@ private constructor( 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(): InputTokenDetails = apply { if (validated) { return@apply @@ -1391,6 +1457,16 @@ private constructor( 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(): TranscriptTextUsageDuration = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionDeltaEvent.kt index 173d83e68..5597e45c7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionDeltaEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionDeltaEvent.kt @@ -343,6 +343,14 @@ private constructor( 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(): ConversationItemInputAudioTranscriptionDeltaEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionFailedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionFailedEvent.kt index 4ece094a6..232962256 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionFailedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionFailedEvent.kt @@ -280,6 +280,14 @@ private constructor( 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(): ConversationItemInputAudioTranscriptionFailedEvent = apply { if (validated) { return@apply @@ -514,6 +522,15 @@ private constructor( 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(): Error = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionSegment.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionSegment.kt index 05a517399..b0dc237a6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionSegment.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemInputAudioTranscriptionSegment.kt @@ -405,6 +405,14 @@ private constructor( 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(): ConversationItemInputAudioTranscriptionSegment = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemRetrieveEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemRetrieveEvent.kt index 3b9a35181..b1c64823d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemRetrieveEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemRetrieveEvent.kt @@ -201,6 +201,14 @@ private constructor( 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(): ConversationItemRetrieveEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncateEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncateEvent.kt index 2cc0f9506..77b888f9a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncateEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncateEvent.kt @@ -287,6 +287,14 @@ private constructor( 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(): ConversationItemTruncateEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncatedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncatedEvent.kt index bafdf3694..b9b9b6638 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncatedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemTruncatedEvent.kt @@ -278,6 +278,14 @@ private constructor( 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(): ConversationItemTruncatedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemWithReference.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemWithReference.kt index 2d395fc35..780c64d81 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemWithReference.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/ConversationItemWithReference.kt @@ -472,6 +472,14 @@ private constructor( 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(): ConversationItemWithReference = apply { if (validated) { return@apply @@ -748,6 +756,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -885,6 +902,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -1029,6 +1056,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -1164,6 +1200,15 @@ private constructor( 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(): Role = apply { if (validated) { return@apply @@ -1300,6 +1345,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply @@ -1440,6 +1494,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferAppendEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferAppendEvent.kt index be187fdcf..2d5d0fb80 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferAppendEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferAppendEvent.kt @@ -212,6 +212,14 @@ private constructor( 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(): InputAudioBufferAppendEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearEvent.kt index 951a97544..1951b485e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearEvent.kt @@ -150,6 +150,14 @@ private constructor( 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(): InputAudioBufferClearEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearedEvent.kt index 65feab3dd..5f164911d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferClearedEvent.kt @@ -166,6 +166,14 @@ private constructor( 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(): InputAudioBufferClearedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommitEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommitEvent.kt index ce8fce21b..8f6834758 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommitEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommitEvent.kt @@ -156,6 +156,14 @@ private constructor( 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(): InputAudioBufferCommitEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommittedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommittedEvent.kt index 34d124976..2ad51abaa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommittedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferCommittedEvent.kt @@ -251,6 +251,14 @@ private constructor( 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(): InputAudioBufferCommittedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt index 01f67ebf5..369eb0153 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferDtmfEventReceivedEvent.kt @@ -204,6 +204,14 @@ private constructor( 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(): InputAudioBufferDtmfEventReceivedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStartedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStartedEvent.kt index e563352ed..434930586 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStartedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStartedEvent.kt @@ -253,6 +253,14 @@ private constructor( 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(): InputAudioBufferSpeechStartedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStoppedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStoppedEvent.kt index deb08ef25..059c299ad 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStoppedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferSpeechStoppedEvent.kt @@ -244,6 +244,14 @@ private constructor( 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(): InputAudioBufferSpeechStoppedEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferTimeoutTriggered.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferTimeoutTriggered.kt index 9dd23ad8d..048e25d9e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferTimeoutTriggered.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/InputAudioBufferTimeoutTriggered.kt @@ -294,6 +294,14 @@ private constructor( 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(): InputAudioBufferTimeoutTriggered = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/LogProbProperties.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/LogProbProperties.kt index 81e6eb5fc..2bfe59576 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/LogProbProperties.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/LogProbProperties.kt @@ -213,6 +213,14 @@ private constructor( 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(): LogProbProperties = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsCompleted.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsCompleted.kt index 25b28a240..b7234cc4c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsCompleted.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsCompleted.kt @@ -196,6 +196,14 @@ private constructor( 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(): McpListToolsCompleted = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsFailed.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsFailed.kt index 4bae5c849..93fdf5573 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsFailed.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsFailed.kt @@ -196,6 +196,14 @@ private constructor( 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(): McpListToolsFailed = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsInProgress.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsInProgress.kt index fa895aa9a..2a2dec032 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsInProgress.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/McpListToolsInProgress.kt @@ -196,6 +196,14 @@ private constructor( 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(): McpListToolsInProgress = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/NoiseReductionType.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/NoiseReductionType.kt index 7b9326ba5..c77521894 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/NoiseReductionType.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/NoiseReductionType.kt @@ -100,6 +100,14 @@ class NoiseReductionType @JsonCreator private constructor(private val value: Jso 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(): NoiseReductionType = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt index f07856af0..3a7c07af0 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/OutputAudioBufferClearEvent.kt @@ -152,6 +152,14 @@ private constructor( 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(): OutputAudioBufferClearEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RateLimitsUpdatedEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RateLimitsUpdatedEvent.kt index 00584b0ff..afcf97331 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RateLimitsUpdatedEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RateLimitsUpdatedEvent.kt @@ -224,6 +224,14 @@ private constructor( 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(): RateLimitsUpdatedEvent = apply { if (validated) { return@apply @@ -459,6 +467,15 @@ private constructor( 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(): RateLimit = apply { if (validated) { return@apply @@ -582,6 +599,16 @@ private constructor( 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(): Name = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfig.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfig.kt index 0cfe1036d..a54c24e0b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfig.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfig.kt @@ -147,6 +147,14 @@ private constructor( 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(): RealtimeAudioConfig = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigInput.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigInput.kt index 511a96e6b..b93ce9159 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigInput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigInput.kt @@ -313,6 +313,14 @@ private constructor( 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(): RealtimeAudioConfigInput = apply { if (validated) { return@apply @@ -457,6 +465,15 @@ private constructor( 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(): NoiseReduction = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigOutput.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigOutput.kt index c7c2e6528..1959d3fac 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigOutput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioConfigOutput.kt @@ -235,6 +235,14 @@ private constructor( 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(): RealtimeAudioConfigOutput = apply { if (validated) { return@apply @@ -304,6 +312,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = voice.accept(new Voice.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -314,6 +351,15 @@ private constructor( 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(): Voice = apply { if (validated) { return@apply @@ -613,6 +659,16 @@ private constructor( 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(): UnionMember1 = apply { if (validated) { return@apply @@ -768,6 +824,16 @@ private constructor( 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(): Id = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioFormats.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioFormats.kt index 05771f6c3..9069d1aad 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioFormats.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioFormats.kt @@ -64,6 +64,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeAudioFormats.accept(new RealtimeAudioFormats.Visitor>() { + * @Override + * public Optional visitAudioPcm(AudioPcm audioPcm) { + * return Optional.of(audioPcm.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { audioPcm != null -> visitor.visitAudioPcm(audioPcm) @@ -74,6 +103,14 @@ private constructor( 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(): RealtimeAudioFormats = apply { if (validated) { return@apply @@ -366,6 +403,15 @@ private constructor( 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(): AudioPcm = apply { if (validated) { return@apply @@ -476,6 +522,16 @@ private constructor( 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(): Rate = apply { if (validated) { return@apply @@ -598,6 +654,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -754,6 +820,15 @@ private constructor( 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(): AudioPcmu = apply { if (validated) { return@apply @@ -863,6 +938,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -1018,6 +1103,15 @@ private constructor( 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(): AudioPcma = apply { if (validated) { return@apply @@ -1127,6 +1221,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt index 198924a6a..2ec4b51bb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeAudioInputTurnDetection.kt @@ -79,6 +79,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeAudioInputTurnDetection.accept(new RealtimeAudioInputTurnDetection.Visitor>() { + * @Override + * public Optional visitServerVad(ServerVad serverVad) { + * return Optional.of(serverVad.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { serverVad != null -> visitor.visitServerVad(serverVad) @@ -88,6 +117,14 @@ private constructor( 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(): RealtimeAudioInputTurnDetection = apply { if (validated) { return@apply @@ -670,6 +707,15 @@ private constructor( 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(): ServerVad = apply { if (validated) { return@apply @@ -983,6 +1029,15 @@ private constructor( 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(): SemanticVad = apply { if (validated) { return@apply @@ -1131,6 +1186,16 @@ private constructor( 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(): Eagerness = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt index 897150aaf..dee76b952 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeClientEvent.kt @@ -335,6 +335,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeClientEvent.accept(new RealtimeClientEvent.Visitor>() { + * @Override + * public Optional visitConversationItemCreate(ConversationItemCreateEvent conversationItemCreate) { + * return Optional.of(conversationItemCreate.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { conversationItemCreate != null -> @@ -361,6 +390,14 @@ private constructor( 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(): RealtimeClientEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemAssistantMessage.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemAssistantMessage.kt index 97d947199..71b3f82f2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemAssistantMessage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemAssistantMessage.kt @@ -320,6 +320,14 @@ private constructor( 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(): RealtimeConversationItemAssistantMessage = apply { if (validated) { return@apply @@ -573,6 +581,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -699,6 +716,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -845,6 +872,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -977,6 +1013,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCall.kt index 48960cc68..ec20253b4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCall.kt @@ -338,6 +338,14 @@ private constructor( 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(): RealtimeConversationItemFunctionCall = apply { if (validated) { return@apply @@ -465,6 +473,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -597,6 +614,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCallOutput.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCallOutput.kt index ca8558ae7..0f03fa82d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCallOutput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemFunctionCallOutput.kt @@ -306,6 +306,14 @@ private constructor( 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(): RealtimeConversationItemFunctionCallOutput = apply { if (validated) { return@apply @@ -431,6 +439,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -563,6 +580,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemSystemMessage.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemSystemMessage.kt index c44061569..d2607533e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemSystemMessage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemSystemMessage.kt @@ -326,6 +326,14 @@ private constructor( 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(): RealtimeConversationItemSystemMessage = apply { if (validated) { return@apply @@ -499,6 +507,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -611,6 +628,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -753,6 +780,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -885,6 +921,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemUserMessage.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemUserMessage.kt index 7b5db5e96..2532f0703 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemUserMessage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeConversationItemUserMessage.kt @@ -320,6 +320,14 @@ private constructor( 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(): RealtimeConversationItemUserMessage = apply { if (validated) { return@apply @@ -647,6 +655,15 @@ private constructor( 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(): Content = apply { if (validated) { return@apply @@ -782,6 +799,16 @@ private constructor( 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(): Detail = apply { if (validated) { return@apply @@ -916,6 +943,16 @@ private constructor( 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(): Type = apply { if (validated) { return@apply @@ -1064,6 +1101,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -1196,6 +1242,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeError.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeError.kt index 6f5c0965c..f71204615 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeError.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeError.kt @@ -268,6 +268,14 @@ private constructor( 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(): RealtimeError = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeErrorEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeErrorEvent.kt index 087486059..c1beb86a8 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeErrorEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeErrorEvent.kt @@ -202,6 +202,14 @@ private constructor( 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(): RealtimeErrorEvent = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeFunctionTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeFunctionTool.kt index 8a0b9a269..afb58eafb 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeFunctionTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeFunctionTool.kt @@ -205,6 +205,14 @@ private constructor( 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(): RealtimeFunctionTool = apply { if (validated) { return@apply @@ -317,6 +325,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalRequest.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalRequest.kt index ee20412f0..d3e727ff6 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalRequest.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalRequest.kt @@ -268,6 +268,14 @@ private constructor( 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(): RealtimeMcpApprovalRequest = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalResponse.kt index 897c11bd2..ff683c442 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpApprovalResponse.kt @@ -274,6 +274,14 @@ private constructor( 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(): RealtimeMcpApprovalResponse = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpListTools.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpListTools.kt index 68341039a..641a5fce1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpListTools.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpListTools.kt @@ -249,6 +249,14 @@ private constructor( 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(): RealtimeMcpListTools = apply { if (validated) { return@apply @@ -481,6 +489,15 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpProtocolError.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpProtocolError.kt index d1de831aa..2177f6c1f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpProtocolError.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpProtocolError.kt @@ -187,6 +187,14 @@ private constructor( 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(): RealtimeMcpProtocolError = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolCall.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolCall.kt index e3f3c6a50..2d5a5a65c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolCall.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolCall.kt @@ -423,6 +423,14 @@ private constructor( 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(): RealtimeMcpToolCall = apply { if (validated) { return@apply @@ -500,6 +508,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = error.accept(new Error.Visitor>() { + * @Override + * public Optional visitProtocol(RealtimeMcpProtocolError protocol) { + * return Optional.of(protocol.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { protocol != null -> visitor.visitProtocol(protocol) @@ -510,6 +547,15 @@ private constructor( 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(): Error = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolExecutionError.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolExecutionError.kt index 1e708c391..d705195d4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolExecutionError.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcpToolExecutionError.kt @@ -158,6 +158,14 @@ private constructor( 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(): RealtimeMcpToolExecutionError = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcphttpError.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcphttpError.kt index 5ebe0acd8..1e6e4297b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcphttpError.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeMcphttpError.kt @@ -187,6 +187,14 @@ private constructor( 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(): RealtimeMcphttpError = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponse.kt index bf5c7b22c..5bf170892 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponse.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponse.kt @@ -684,6 +684,14 @@ private constructor( 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(): RealtimeResponse = apply { if (validated) { return@apply @@ -826,6 +834,15 @@ private constructor( 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(): Audio = apply { if (validated) { return@apply @@ -1020,6 +1037,16 @@ private constructor( 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(): Output = apply { if (validated) { return@apply @@ -1196,6 +1223,16 @@ private constructor( 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(): Voice = apply { if (validated) { return@apply @@ -1298,6 +1335,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = maxOutputTokens.accept(new MaxOutputTokens.Visitor>() { + * @Override + * public Optional visitInteger(Long integer) { + * return Optional.of(integer.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { integer != null -> visitor.visitInteger(integer) @@ -1307,6 +1373,15 @@ private constructor( 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(): MaxOutputTokens = apply { if (validated) { return@apply @@ -1518,6 +1593,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1641,6 +1725,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -1770,6 +1863,15 @@ private constructor( 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(): OutputModality = apply { if (validated) { return@apply @@ -1917,6 +2019,15 @@ private constructor( 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(): Status = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateAudioOutput.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateAudioOutput.kt index a5b636cbd..5c961e2b1 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateAudioOutput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateAudioOutput.kt @@ -130,6 +130,14 @@ private constructor( 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(): RealtimeResponseCreateAudioOutput = apply { if (validated) { return@apply @@ -318,6 +326,15 @@ private constructor( 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(): Output = apply { if (validated) { return@apply @@ -386,6 +403,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = voice.accept(new Voice.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { string != null -> visitor.visitString(string) @@ -396,6 +443,16 @@ private constructor( 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(): Voice = apply { if (validated) { return@apply @@ -699,6 +756,16 @@ private constructor( 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(): UnionMember1 = apply { if (validated) { return@apply @@ -855,6 +922,16 @@ private constructor( 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(): Id = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateMcpTool.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateMcpTool.kt index 7eb9809c5..34a6fad2a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateMcpTool.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateMcpTool.kt @@ -563,6 +563,14 @@ private constructor( 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(): RealtimeResponseCreateMcpTool = apply { if (validated) { return@apply @@ -639,6 +647,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = allowedTools.accept(new AllowedTools.Visitor>() { + * @Override + * public Optional visitMcp(List mcp) { + * return Optional.of(mcp.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { mcp != null -> visitor.visitMcp(mcp) @@ -648,6 +685,15 @@ private constructor( 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(): AllowedTools = apply { if (validated) { return@apply @@ -963,6 +1009,16 @@ private constructor( 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(): McpToolFilter = apply { if (validated) { return@apply @@ -1155,6 +1211,15 @@ private constructor( 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(): ConnectorId = apply { if (validated) { return@apply @@ -1254,6 +1319,15 @@ private constructor( 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(): Headers = apply { if (validated) { return@apply @@ -1341,6 +1415,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = requireApproval.accept(new RequireApproval.Visitor>() { + * @Override + * public Optional visitMcpToolApprovalFilter(McpToolApprovalFilter mcpToolApprovalFilter) { + * return Optional.of(mcpToolApprovalFilter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { mcpToolApprovalFilter != null -> @@ -1352,6 +1455,15 @@ private constructor( 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(): RequireApproval = apply { if (validated) { return@apply @@ -1671,6 +1783,16 @@ private constructor( 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(): McpToolApprovalFilter = apply { if (validated) { return@apply @@ -1870,6 +1992,16 @@ private constructor( 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(): Always = apply { if (validated) { return@apply @@ -2090,6 +2222,16 @@ private constructor( 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(): Never = apply { if (validated) { return@apply @@ -2261,6 +2403,16 @@ private constructor( 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(): McpToolApprovalSetting = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateParams.kt index 9aa9c556e..628ef17b7 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseCreateParams.kt @@ -730,6 +730,14 @@ private constructor( 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(): RealtimeResponseCreateParams = apply { if (validated) { return@apply @@ -870,6 +878,15 @@ private constructor( 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(): Conversation = apply { if (validated) { return@apply @@ -936,6 +953,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = maxOutputTokens.accept(new MaxOutputTokens.Visitor>() { + * @Override + * public Optional visitInteger(Long integer) { + * return Optional.of(integer.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { integer != null -> visitor.visitInteger(integer) @@ -945,6 +991,15 @@ private constructor( 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(): MaxOutputTokens = apply { if (validated) { return@apply @@ -1156,6 +1211,15 @@ private constructor( 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(): Metadata = apply { if (validated) { return@apply @@ -1288,6 +1352,15 @@ private constructor( 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(): OutputModality = apply { if (validated) { return@apply @@ -1384,6 +1457,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = toolChoice.accept(new ToolChoice.Visitor>() { + * @Override + * public Optional visitOptions(ToolChoiceOptions options) { + * return Optional.of(options.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { options != null -> visitor.visitOptions(options) @@ -1394,6 +1496,15 @@ private constructor( 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(): ToolChoice = apply { if (validated) { return@apply @@ -1623,6 +1734,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tool.accept(new Tool.Visitor>() { + * @Override + * public Optional visitRealtimeFunction(RealtimeFunctionTool realtimeFunction) { + * return Optional.of(realtimeFunction.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { realtimeFunction != null -> visitor.visitRealtimeFunction(realtimeFunction) @@ -1633,6 +1773,15 @@ private constructor( 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(): Tool = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseStatus.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseStatus.kt index 532bb346b..959971317 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseStatus.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseStatus.kt @@ -193,6 +193,14 @@ private constructor( 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(): RealtimeResponseStatus = apply { if (validated) { return@apply @@ -356,6 +364,15 @@ private constructor( 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(): Error = apply { if (validated) { return@apply @@ -508,6 +525,15 @@ private constructor( 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(): Reason = apply { if (validated) { return@apply @@ -649,6 +675,15 @@ private constructor( 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(): Type = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsage.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsage.kt index ccd860f90..c9b3015e2 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsage.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsage.kt @@ -298,6 +298,14 @@ private constructor( 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(): RealtimeResponseUsage = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageInputTokenDetails.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageInputTokenDetails.kt index 3883146f6..cfced353b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageInputTokenDetails.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageInputTokenDetails.kt @@ -281,6 +281,14 @@ private constructor( 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(): RealtimeResponseUsageInputTokenDetails = apply { if (validated) { return@apply @@ -492,6 +500,15 @@ private constructor( 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(): CachedTokensDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageOutputTokenDetails.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageOutputTokenDetails.kt index b1a93ec3d..3a5b5d3fc 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageOutputTokenDetails.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeResponseUsageOutputTokenDetails.kt @@ -157,6 +157,14 @@ private constructor( 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(): RealtimeResponseUsageOutputTokenDetails = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt index 9f5c943d3..7c36c7f7b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeServerEvent.kt @@ -888,6 +888,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeServerEvent.accept(new RealtimeServerEvent.Visitor>() { + * @Override + * public Optional visitConversationCreated(ConversationCreatedEvent conversationCreated) { + * return Optional.of(conversationCreated.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { conversationCreated != null -> visitor.visitConversationCreated(conversationCreated) @@ -986,6 +1015,14 @@ private constructor( 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(): RealtimeServerEvent = apply { if (validated) { return@apply @@ -3181,6 +3218,15 @@ private constructor( 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(): ConversationItemRetrieved = apply { if (validated) { return@apply @@ -3430,6 +3476,15 @@ private constructor( 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(): OutputAudioBufferStarted = apply { if (validated) { return@apply @@ -3679,6 +3734,15 @@ private constructor( 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(): OutputAudioBufferStopped = apply { if (validated) { return@apply @@ -3929,6 +3993,15 @@ private constructor( 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(): OutputAudioBufferCleared = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt index 5cdfe031d..52a26105f 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSession.kt @@ -1054,6 +1054,14 @@ private constructor( 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(): RealtimeSession = apply { if (validated) { return@apply @@ -1203,6 +1211,15 @@ private constructor( 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(): Include = apply { if (validated) { return@apply @@ -1343,6 +1360,15 @@ private constructor( 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(): InputAudioFormat = apply { if (validated) { return@apply @@ -1496,6 +1522,15 @@ private constructor( 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(): InputAudioNoiseReduction = apply { if (validated) { return@apply @@ -1567,6 +1602,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = maxResponseOutputTokens.accept(new MaxResponseOutputTokens.Visitor>() { + * @Override + * public Optional visitInteger(Long integer) { + * return Optional.of(integer.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { integer != null -> visitor.visitInteger(integer) @@ -1576,6 +1640,15 @@ private constructor( 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(): MaxResponseOutputTokens = apply { if (validated) { return@apply @@ -1810,6 +1883,15 @@ private constructor( 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(): Modality = apply { if (validated) { return@apply @@ -2027,6 +2109,15 @@ private constructor( 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(): Model = apply { if (validated) { return@apply @@ -2147,6 +2238,15 @@ private constructor( 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(): Object = apply { if (validated) { return@apply @@ -2286,6 +2386,15 @@ private constructor( 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(): OutputAudioFormat = apply { if (validated) { return@apply @@ -2358,6 +2467,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = tracing.accept(new Tracing.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -2367,6 +2505,15 @@ private constructor( 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(): Tracing = apply { if (validated) { return@apply @@ -2699,6 +2846,16 @@ private constructor( 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(): TracingConfiguration = apply { if (validated) { return@apply @@ -2803,6 +2960,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = turnDetection.accept(new TurnDetection.Visitor>() { + * @Override + * public Optional visitServerVad(ServerVad serverVad) { + * return Optional.of(serverVad.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { serverVad != null -> visitor.visitServerVad(serverVad) @@ -2812,6 +2998,15 @@ private constructor( 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(): TurnDetection = apply { if (validated) { return@apply @@ -3398,6 +3593,16 @@ private constructor( 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(): ServerVad = apply { if (validated) { return@apply @@ -3720,6 +3925,16 @@ private constructor( 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(): SemanticVad = apply { if (validated) { return@apply @@ -3868,6 +4083,16 @@ private constructor( 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(): Eagerness = apply { if (validated) { return@apply @@ -4076,6 +4301,15 @@ private constructor( 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(): Voice = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt index 2557626d9..b1c7187d3 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeSessionCreateRequest.kt @@ -763,6 +763,14 @@ private constructor( 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(): RealtimeSessionCreateRequest = apply { if (validated) { return@apply @@ -900,6 +908,15 @@ private constructor( 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(): Include = apply { if (validated) { return@apply @@ -966,6 +983,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = maxOutputTokens.accept(new MaxOutputTokens.Visitor>() { + * @Override + * public Optional visitInteger(Long integer) { + * return Optional.of(integer.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { integer != null -> visitor.visitInteger(integer) @@ -975,6 +1021,15 @@ private constructor( 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(): MaxOutputTokens = apply { if (validated) { return@apply @@ -1299,6 +1354,15 @@ private constructor( 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(): Model = apply { if (validated) { return@apply @@ -1428,6 +1492,15 @@ private constructor( 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(): OutputModality = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolChoiceConfig.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolChoiceConfig.kt index 9682f8914..b07ee6050 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolChoiceConfig.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolChoiceConfig.kt @@ -78,6 +78,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeToolChoiceConfig.accept(new RealtimeToolChoiceConfig.Visitor>() { + * @Override + * public Optional visitToolChoiceOptions(ToolChoiceOptions toolChoiceOptions) { + * return Optional.of(toolChoiceOptions.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { toolChoiceOptions != null -> visitor.visitToolChoiceOptions(toolChoiceOptions) @@ -88,6 +117,14 @@ private constructor( 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(): RealtimeToolChoiceConfig = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolsConfigUnion.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolsConfigUnion.kt index d9ec7606d..7180d1535 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolsConfigUnion.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeToolsConfigUnion.kt @@ -66,6 +66,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeToolsConfigUnion.accept(new RealtimeToolsConfigUnion.Visitor>() { + * @Override + * public Optional visitFunction(RealtimeFunctionTool function) { + * return Optional.of(function.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { function != null -> visitor.visitFunction(function) @@ -75,6 +104,14 @@ private constructor( 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(): RealtimeToolsConfigUnion = apply { if (validated) { return@apply @@ -768,6 +805,15 @@ private constructor( 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(): Mcp = apply { if (validated) { return@apply @@ -845,6 +891,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = allowedTools.accept(new AllowedTools.Visitor>() { + * @Override + * public Optional visitMcp(List mcp) { + * return Optional.of(mcp.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { mcp != null -> visitor.visitMcp(mcp) @@ -854,6 +930,16 @@ private constructor( 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(): AllowedTools = apply { if (validated) { return@apply @@ -1174,6 +1260,16 @@ private constructor( 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(): McpToolFilter = apply { if (validated) { return@apply @@ -1369,6 +1465,16 @@ private constructor( 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(): ConnectorId = apply { if (validated) { return@apply @@ -1472,6 +1578,16 @@ private constructor( 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(): Headers = apply { if (validated) { return@apply @@ -1559,6 +1675,36 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = requireApproval.accept(new RequireApproval.Visitor>() { + * @Override + * public Optional visitMcpToolApprovalFilter(McpToolApprovalFilter mcpToolApprovalFilter) { + * return Optional.of(mcpToolApprovalFilter.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { mcpToolApprovalFilter != null -> @@ -1570,6 +1716,16 @@ private constructor( 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(): RequireApproval = apply { if (validated) { return@apply @@ -1897,6 +2053,16 @@ private constructor( 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(): McpToolApprovalFilter = apply { if (validated) { return@apply @@ -2100,6 +2266,16 @@ private constructor( 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(): Always = apply { if (validated) { return@apply @@ -2324,6 +2500,16 @@ private constructor( 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(): Never = apply { if (validated) { return@apply @@ -2499,6 +2685,16 @@ private constructor( 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(): McpToolApprovalSetting = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTracingConfig.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTracingConfig.kt index 50e2423dc..604fff36c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTracingConfig.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTracingConfig.kt @@ -63,6 +63,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeTracingConfig.accept(new RealtimeTracingConfig.Visitor>() { + * @Override + * public Optional visitAuto(JsonValue auto) { + * return Optional.of(auto.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { auto != null -> visitor.visitAuto(auto) @@ -72,6 +101,14 @@ private constructor( 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(): RealtimeTracingConfig = apply { if (validated) { return@apply @@ -405,6 +442,15 @@ private constructor( 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(): TracingConfiguration = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudio.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudio.kt index 7a2213308..7ff527594 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudio.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudio.kt @@ -124,6 +124,14 @@ private constructor( 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(): RealtimeTranscriptionSessionAudio = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInput.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInput.kt index 97255cbf2..4aec9e955 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInput.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInput.kt @@ -331,6 +331,14 @@ private constructor( 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(): RealtimeTranscriptionSessionAudioInput = apply { if (validated) { return@apply @@ -475,6 +483,15 @@ private constructor( 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(): NoiseReduction = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt index 8969e7ea5..0c3a7189c 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionAudioInputTurnDetection.kt @@ -79,6 +79,35 @@ private constructor( fun _json(): Optional = Optional.ofNullable(_json) + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeTranscriptionSessionAudioInputTurnDetection.accept(new RealtimeTranscriptionSessionAudioInputTurnDetection.Visitor>() { + * @Override + * public Optional visitServerVad(ServerVad serverVad) { + * return Optional.of(serverVad.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ fun accept(visitor: Visitor): T = when { serverVad != null -> visitor.visitServerVad(serverVad) @@ -88,6 +117,14 @@ private constructor( 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(): RealtimeTranscriptionSessionAudioInputTurnDetection = apply { if (validated) { return@apply @@ -693,6 +730,15 @@ private constructor( 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(): ServerVad = apply { if (validated) { return@apply @@ -1006,6 +1052,15 @@ private constructor( 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(): SemanticVad = apply { if (validated) { return@apply @@ -1154,6 +1209,16 @@ private constructor( 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(): Eagerness = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionCreateRequest.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionCreateRequest.kt index 407a2a88e..0ce48ad02 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionCreateRequest.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranscriptionSessionCreateRequest.kt @@ -221,6 +221,14 @@ private constructor( 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(): RealtimeTranscriptionSessionCreateRequest = apply { if (validated) { return@apply @@ -340,6 +348,15 @@ private constructor( 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(): Include = apply { if (validated) { return@apply diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientEvent.kt new file mode 100644 index 000000000..f06539a86 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientEvent.kt @@ -0,0 +1,396 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.JsonValue +import com.openai.core.getOrThrow +import com.openai.errors.OpenAIInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A Realtime translation client event. */ +@JsonDeserialize(using = RealtimeTranslationClientEvent.Deserializer::class) +@JsonSerialize(using = RealtimeTranslationClientEvent.Serializer::class) +class RealtimeTranslationClientEvent +private constructor( + private val sessionUpdate: RealtimeTranslationSessionUpdateEvent? = null, + private val sessionInputAudioBufferAppend: RealtimeTranslationInputAudioBufferAppendEvent? = + null, + private val sessionClose: RealtimeTranslationSessionCloseEvent? = null, + private val _json: JsonValue? = null, +) { + + /** + * Send this event to update the translation session configuration. Translation sessions support + * updates to `audio.output.language`, `audio.input.transcription`, and + * `audio.input.noise_reduction`. + */ + fun sessionUpdate(): Optional = + Optional.ofNullable(sessionUpdate) + + /** + * Send this event to append audio bytes to the translation session input audio buffer. + * + * WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw + * audio bytes. Unsupported websocket audio formats return a validation error because + * lower-quality audio materially degrades translation quality. + * + * Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms + * chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. + * If a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back. + * + * Keep appending silence while the session is active. If a client stops sending audio and later + * resumes, model time treats the resumed audio as contiguous with the previous audio rather + * than as a real-world pause. + */ + fun sessionInputAudioBufferAppend(): Optional = + Optional.ofNullable(sessionInputAudioBufferAppend) + + /** + * Gracefully close the realtime translation session. The server flushes pending input audio and + * emits any remaining translated output before closing the session. + */ + fun sessionClose(): Optional = + Optional.ofNullable(sessionClose) + + fun isSessionUpdate(): Boolean = sessionUpdate != null + + fun isSessionInputAudioBufferAppend(): Boolean = sessionInputAudioBufferAppend != null + + fun isSessionClose(): Boolean = sessionClose != null + + /** + * Send this event to update the translation session configuration. Translation sessions support + * updates to `audio.output.language`, `audio.input.transcription`, and + * `audio.input.noise_reduction`. + */ + fun asSessionUpdate(): RealtimeTranslationSessionUpdateEvent = + sessionUpdate.getOrThrow("sessionUpdate") + + /** + * Send this event to append audio bytes to the translation session input audio buffer. + * + * WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw + * audio bytes. Unsupported websocket audio formats return a validation error because + * lower-quality audio materially degrades translation quality. + * + * Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms + * chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. + * If a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back. + * + * Keep appending silence while the session is active. If a client stops sending audio and later + * resumes, model time treats the resumed audio as contiguous with the previous audio rather + * than as a real-world pause. + */ + fun asSessionInputAudioBufferAppend(): RealtimeTranslationInputAudioBufferAppendEvent = + sessionInputAudioBufferAppend.getOrThrow("sessionInputAudioBufferAppend") + + /** + * Gracefully close the realtime translation session. The server flushes pending input audio and + * emits any remaining translated output before closing the session. + */ + fun asSessionClose(): RealtimeTranslationSessionCloseEvent = + sessionClose.getOrThrow("sessionClose") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeTranslationClientEvent.accept(new RealtimeTranslationClientEvent.Visitor>() { + * @Override + * public Optional visitSessionUpdate(RealtimeTranslationSessionUpdateEvent sessionUpdate) { + * return Optional.of(sessionUpdate.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + sessionUpdate != null -> visitor.visitSessionUpdate(sessionUpdate) + sessionInputAudioBufferAppend != null -> + visitor.visitSessionInputAudioBufferAppend(sessionInputAudioBufferAppend) + sessionClose != null -> visitor.visitSessionClose(sessionClose) + else -> visitor.unknown(_json) + } + + 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(): RealtimeTranslationClientEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSessionUpdate( + sessionUpdate: RealtimeTranslationSessionUpdateEvent + ) { + sessionUpdate.validate() + } + + override fun visitSessionInputAudioBufferAppend( + sessionInputAudioBufferAppend: RealtimeTranslationInputAudioBufferAppendEvent + ) { + sessionInputAudioBufferAppend.validate() + } + + override fun visitSessionClose(sessionClose: RealtimeTranslationSessionCloseEvent) { + sessionClose.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSessionUpdate( + sessionUpdate: RealtimeTranslationSessionUpdateEvent + ) = sessionUpdate.validity() + + override fun visitSessionInputAudioBufferAppend( + sessionInputAudioBufferAppend: RealtimeTranslationInputAudioBufferAppendEvent + ) = sessionInputAudioBufferAppend.validity() + + override fun visitSessionClose(sessionClose: RealtimeTranslationSessionCloseEvent) = + sessionClose.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationClientEvent && + sessionUpdate == other.sessionUpdate && + sessionInputAudioBufferAppend == other.sessionInputAudioBufferAppend && + sessionClose == other.sessionClose + } + + override fun hashCode(): Int = + Objects.hash(sessionUpdate, sessionInputAudioBufferAppend, sessionClose) + + override fun toString(): String = + when { + sessionUpdate != null -> "RealtimeTranslationClientEvent{sessionUpdate=$sessionUpdate}" + sessionInputAudioBufferAppend != null -> + "RealtimeTranslationClientEvent{sessionInputAudioBufferAppend=$sessionInputAudioBufferAppend}" + sessionClose != null -> "RealtimeTranslationClientEvent{sessionClose=$sessionClose}" + _json != null -> "RealtimeTranslationClientEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RealtimeTranslationClientEvent") + } + + companion object { + + /** + * Send this event to update the translation session configuration. Translation sessions + * support updates to `audio.output.language`, `audio.input.transcription`, and + * `audio.input.noise_reduction`. + */ + @JvmStatic + fun ofSessionUpdate(sessionUpdate: RealtimeTranslationSessionUpdateEvent) = + RealtimeTranslationClientEvent(sessionUpdate = sessionUpdate) + + /** + * Send this event to append audio bytes to the translation session input audio buffer. + * + * WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw + * audio bytes. Unsupported websocket audio formats return a validation error because + * lower-quality audio materially degrades translation quality. + * + * Translation consumes 200 ms engine frames. For best realtime behavior, append audio in + * 200 ms chunks. If a chunk is shorter, the server buffers it until it has enough audio for + * one frame. If a chunk is longer, the server splits it into 200 ms frames and enqueues + * them back-to-back. + * + * Keep appending silence while the session is active. If a client stops sending audio and + * later resumes, model time treats the resumed audio as contiguous with the previous audio + * rather than as a real-world pause. + */ + @JvmStatic + fun ofSessionInputAudioBufferAppend( + sessionInputAudioBufferAppend: RealtimeTranslationInputAudioBufferAppendEvent + ) = + RealtimeTranslationClientEvent( + sessionInputAudioBufferAppend = sessionInputAudioBufferAppend + ) + + /** + * Gracefully close the realtime translation session. The server flushes pending input audio + * and emits any remaining translated output before closing the session. + */ + @JvmStatic + fun ofSessionClose(sessionClose: RealtimeTranslationSessionCloseEvent) = + RealtimeTranslationClientEvent(sessionClose = sessionClose) + } + + /** + * An interface that defines how to map each variant of [RealtimeTranslationClientEvent] to a + * value of type [T]. + */ + interface Visitor { + + /** + * Send this event to update the translation session configuration. Translation sessions + * support updates to `audio.output.language`, `audio.input.transcription`, and + * `audio.input.noise_reduction`. + */ + fun visitSessionUpdate(sessionUpdate: RealtimeTranslationSessionUpdateEvent): T + + /** + * Send this event to append audio bytes to the translation session input audio buffer. + * + * WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw + * audio bytes. Unsupported websocket audio formats return a validation error because + * lower-quality audio materially degrades translation quality. + * + * Translation consumes 200 ms engine frames. For best realtime behavior, append audio in + * 200 ms chunks. If a chunk is shorter, the server buffers it until it has enough audio for + * one frame. If a chunk is longer, the server splits it into 200 ms frames and enqueues + * them back-to-back. + * + * Keep appending silence while the session is active. If a client stops sending audio and + * later resumes, model time treats the resumed audio as contiguous with the previous audio + * rather than as a real-world pause. + */ + fun visitSessionInputAudioBufferAppend( + sessionInputAudioBufferAppend: RealtimeTranslationInputAudioBufferAppendEvent + ): T + + /** + * Gracefully close the realtime translation session. The server flushes pending input audio + * and emits any remaining translated output before closing the session. + */ + fun visitSessionClose(sessionClose: RealtimeTranslationSessionCloseEvent): T + + /** + * Maps an unknown variant of [RealtimeTranslationClientEvent] to a value of type [T]. + * + * An instance of [RealtimeTranslationClientEvent] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown RealtimeTranslationClientEvent: $json") + } + } + + internal class Deserializer : + BaseDeserializer(RealtimeTranslationClientEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RealtimeTranslationClientEvent { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "session.update" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RealtimeTranslationClientEvent(sessionUpdate = it, _json = json) } + ?: RealtimeTranslationClientEvent(_json = json) + } + "session.input_audio_buffer.append" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + RealtimeTranslationClientEvent( + sessionInputAudioBufferAppend = it, + _json = json, + ) + } ?: RealtimeTranslationClientEvent(_json = json) + } + "session.close" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RealtimeTranslationClientEvent(sessionClose = it, _json = json) } + ?: RealtimeTranslationClientEvent(_json = json) + } + } + + return RealtimeTranslationClientEvent(_json = json) + } + } + + internal class Serializer : + BaseSerializer(RealtimeTranslationClientEvent::class) { + + override fun serialize( + value: RealtimeTranslationClientEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.sessionUpdate != null -> generator.writeObject(value.sessionUpdate) + value.sessionInputAudioBufferAppend != null -> + generator.writeObject(value.sessionInputAudioBufferAppend) + value.sessionClose != null -> generator.writeObject(value.sessionClose) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RealtimeTranslationClientEvent") + } + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientSecretCreateRequest.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientSecretCreateRequest.kt new file mode 100644 index 000000000..388df8559 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientSecretCreateRequest.kt @@ -0,0 +1,594 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.Enum +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a translation session and client secret for the Realtime API. */ +class RealtimeTranslationClientSecretCreateRequest +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val session: JsonField, + private val expiresAfter: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("session") + @ExcludeMissing + session: JsonField = JsonMissing.of(), + @JsonProperty("expires_after") + @ExcludeMissing + expiresAfter: JsonField = JsonMissing.of(), + ) : this(session, expiresAfter, mutableMapOf()) + + /** + * Realtime translation session configuration. Translation sessions stream source audio in and + * translated audio plus transcript deltas out continuously. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun session(): RealtimeTranslationSessionCreateRequest = session.getRequired("session") + + /** + * Configuration for the client secret expiration. Expiration refers to the time after which a + * client secret will no longer be valid for creating sessions. The session itself may continue + * after that time once started. A secret can be used to create multiple sessions until it + * expires. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresAfter(): Optional = expiresAfter.getOptional("expires_after") + + /** + * Returns the raw JSON value of [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") + @ExcludeMissing + fun _session(): JsonField = session + + /** + * Returns the raw JSON value of [expiresAfter]. + * + * Unlike [expiresAfter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_after") + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter + + @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 + * [RealtimeTranslationClientSecretCreateRequest]. + * + * The following fields are required: + * ```java + * .session() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RealtimeTranslationClientSecretCreateRequest]. */ + class Builder internal constructor() { + + private var session: JsonField? = null + private var expiresAfter: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + realtimeTranslationClientSecretCreateRequest: + RealtimeTranslationClientSecretCreateRequest + ) = apply { + session = realtimeTranslationClientSecretCreateRequest.session + expiresAfter = realtimeTranslationClientSecretCreateRequest.expiresAfter + additionalProperties = + realtimeTranslationClientSecretCreateRequest.additionalProperties.toMutableMap() + } + + /** + * Realtime translation session configuration. Translation sessions stream source audio in + * and translated audio plus transcript deltas out continuously. + */ + fun session(session: RealtimeTranslationSessionCreateRequest) = + session(JsonField.of(session)) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed + * [RealtimeTranslationSessionCreateRequest] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun session(session: JsonField) = apply { + this.session = session + } + + /** + * Configuration for the client secret expiration. Expiration refers to the time after which + * a client secret will no longer be valid for creating sessions. The session itself may + * continue after that time once started. A secret can be used to create multiple sessions + * until it expires. + */ + fun expiresAfter(expiresAfter: ExpiresAfter) = expiresAfter(JsonField.of(expiresAfter)) + + /** + * Sets [Builder.expiresAfter] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAfter] with a well-typed [ExpiresAfter] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAfter(expiresAfter: JsonField) = apply { + this.expiresAfter = expiresAfter + } + + 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 [RealtimeTranslationClientSecretCreateRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .session() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RealtimeTranslationClientSecretCreateRequest = + RealtimeTranslationClientSecretCreateRequest( + checkRequired("session", session), + expiresAfter, + 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(): RealtimeTranslationClientSecretCreateRequest = apply { + if (validated) { + return@apply + } + + session().validate() + expiresAfter().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (session.asKnown().getOrNull()?.validity() ?: 0) + + (expiresAfter.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Configuration for the client secret expiration. Expiration refers to the time after which a + * client secret will no longer be valid for creating sessions. The session itself may continue + * after that time once started. A secret can be used to create multiple sessions until it + * expires. + */ + class ExpiresAfter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val anchor: JsonField, + private val seconds: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("anchor") @ExcludeMissing anchor: JsonField = JsonMissing.of(), + @JsonProperty("seconds") @ExcludeMissing seconds: JsonField = JsonMissing.of(), + ) : this(anchor, seconds, mutableMapOf()) + + /** + * The anchor point for the client secret expiration, meaning that `seconds` will be added + * to the `created_at` time of the client secret to produce an expiration timestamp. Only + * `created_at` is currently supported. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun anchor(): Optional = anchor.getOptional("anchor") + + /** + * The number of seconds from the anchor point to the expiration. Select a value between + * `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun seconds(): Optional = seconds.getOptional("seconds") + + /** + * Returns the raw JSON value of [anchor]. + * + * Unlike [anchor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("anchor") @ExcludeMissing fun _anchor(): JsonField = anchor + + /** + * Returns the raw JSON value of [seconds]. + * + * Unlike [seconds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("seconds") @ExcludeMissing fun _seconds(): JsonField = seconds + + @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 [ExpiresAfter]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExpiresAfter]. */ + class Builder internal constructor() { + + private var anchor: JsonField = JsonMissing.of() + private var seconds: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(expiresAfter: ExpiresAfter) = apply { + anchor = expiresAfter.anchor + seconds = expiresAfter.seconds + additionalProperties = expiresAfter.additionalProperties.toMutableMap() + } + + /** + * The anchor point for the client secret expiration, meaning that `seconds` will be + * added to the `created_at` time of the client secret to produce an expiration + * timestamp. Only `created_at` is currently supported. + */ + fun anchor(anchor: Anchor) = anchor(JsonField.of(anchor)) + + /** + * Sets [Builder.anchor] to an arbitrary JSON value. + * + * You should usually call [Builder.anchor] with a well-typed [Anchor] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun anchor(anchor: JsonField) = apply { this.anchor = anchor } + + /** + * The number of seconds from the anchor point to the expiration. Select a value between + * `10` and `7200` (2 hours). This default to 600 seconds (10 minutes) if not specified. + */ + fun seconds(seconds: Long) = seconds(JsonField.of(seconds)) + + /** + * Sets [Builder.seconds] to an arbitrary JSON value. + * + * You should usually call [Builder.seconds] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun seconds(seconds: JsonField) = apply { this.seconds = seconds } + + 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 [ExpiresAfter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExpiresAfter = + ExpiresAfter(anchor, seconds, 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(): ExpiresAfter = apply { + if (validated) { + return@apply + } + + anchor().ifPresent { it.validate() } + seconds() + 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 = + (anchor.asKnown().getOrNull()?.validity() ?: 0) + + (if (seconds.asKnown().isPresent) 1 else 0) + + /** + * The anchor point for the client secret expiration, meaning that `seconds` will be added + * to the `created_at` time of the client secret to produce an expiration timestamp. Only + * `created_at` is currently supported. + */ + class Anchor @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 CREATED_AT = of("created_at") + + @JvmStatic fun of(value: String) = Anchor(JsonField.of(value)) + } + + /** An enum containing [Anchor]'s known values. */ + enum class Known { + CREATED_AT + } + + /** + * An enum containing [Anchor]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Anchor] 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 { + CREATED_AT, + /** + * An enum member indicating that [Anchor] 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) { + CREATED_AT -> Value.CREATED_AT + 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) { + CREATED_AT -> Known.CREATED_AT + else -> throw OpenAIInvalidDataException("Unknown Anchor: $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(): Anchor = 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 Anchor && 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 ExpiresAfter && + anchor == other.anchor && + seconds == other.seconds && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(anchor, seconds, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExpiresAfter{anchor=$anchor, seconds=$seconds, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationClientSecretCreateRequest && + session == other.session && + expiresAfter == other.expiresAfter && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(session, expiresAfter, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RealtimeTranslationClientSecretCreateRequest{session=$session, expiresAfter=$expiresAfter, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientSecretCreateResponse.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientSecretCreateResponse.kt new file mode 100644 index 000000000..e5a62d24b --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationClientSecretCreateResponse.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Response from creating a translation session and client secret for the Realtime API. */ +class RealtimeTranslationClientSecretCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val expiresAt: JsonField, + private val session: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("expires_at") @ExcludeMissing expiresAt: JsonField = JsonMissing.of(), + @JsonProperty("session") + @ExcludeMissing + session: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(expiresAt, session, value, mutableMapOf()) + + /** + * Expiration timestamp for the client secret, in seconds since epoch. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expiresAt(): Long = expiresAt.getRequired("expires_at") + + /** + * A Realtime translation session. Translation sessions continuously translate input audio into + * the configured output language. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun session(): RealtimeTranslationSession = session.getRequired("session") + + /** + * The generated client secret value. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * 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 [session]. + * + * Unlike [session], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session") + @ExcludeMissing + fun _session(): JsonField = session + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 + * [RealtimeTranslationClientSecretCreateResponse]. + * + * The following fields are required: + * ```java + * .expiresAt() + * .session() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RealtimeTranslationClientSecretCreateResponse]. */ + class Builder internal constructor() { + + private var expiresAt: JsonField? = null + private var session: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + realtimeTranslationClientSecretCreateResponse: + RealtimeTranslationClientSecretCreateResponse + ) = apply { + expiresAt = realtimeTranslationClientSecretCreateResponse.expiresAt + session = realtimeTranslationClientSecretCreateResponse.session + value = realtimeTranslationClientSecretCreateResponse.value + additionalProperties = + realtimeTranslationClientSecretCreateResponse.additionalProperties.toMutableMap() + } + + /** Expiration timestamp for the client secret, in seconds since epoch. */ + fun expiresAt(expiresAt: Long) = expiresAt(JsonField.of(expiresAt)) + + /** + * 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 } + + /** + * A Realtime translation session. Translation sessions continuously translate input audio + * into the configured output language. + */ + fun session(session: RealtimeTranslationSession) = session(JsonField.of(session)) + + /** + * Sets [Builder.session] to an arbitrary JSON value. + * + * You should usually call [Builder.session] with a well-typed [RealtimeTranslationSession] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun session(session: JsonField) = apply { + this.session = session + } + + /** The generated client secret value. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [RealtimeTranslationClientSecretCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expiresAt() + * .session() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RealtimeTranslationClientSecretCreateResponse = + RealtimeTranslationClientSecretCreateResponse( + checkRequired("expiresAt", expiresAt), + checkRequired("session", session), + checkRequired("value", value), + 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(): RealtimeTranslationClientSecretCreateResponse = apply { + if (validated) { + return@apply + } + + expiresAt() + session().validate() + value() + 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 (expiresAt.asKnown().isPresent) 1 else 0) + + (session.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationClientSecretCreateResponse && + expiresAt == other.expiresAt && + session == other.session && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expiresAt, session, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RealtimeTranslationClientSecretCreateResponse{expiresAt=$expiresAt, session=$session, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationInputAudioBufferAppendEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationInputAudioBufferAppendEvent.kt new file mode 100644 index 000000000..6cbb6175c --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationInputAudioBufferAppendEvent.kt @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Send this event to append audio bytes to the translation session input audio buffer. + * + * WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw audio + * bytes. Unsupported websocket audio formats return a validation error because lower-quality audio + * materially degrades translation quality. + * + * Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms + * chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. If + * a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back. + * + * Keep appending silence while the session is active. If a client stops sending audio and later + * resumes, model time treats the resumed audio as contiguous with the previous audio rather than as + * a real-world pause. + */ +class RealtimeTranslationInputAudioBufferAppendEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val audio: JsonField, + private val type: JsonValue, + private val eventId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("audio") @ExcludeMissing audio: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("event_id") @ExcludeMissing eventId: JsonField = JsonMissing.of(), + ) : this(audio, type, eventId, mutableMapOf()) + + /** + * Base64-encoded 24 kHz PCM16 mono audio bytes. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun audio(): String = audio.getRequired("audio") + + /** + * The event type, must be `session.input_audio_buffer.append`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("session.input_audio_buffer.append") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Optional client-generated ID used to identify this event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventId(): Optional = eventId.getOptional("event_id") + + /** + * Returns the raw JSON value of [audio]. + * + * Unlike [audio], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audio") @ExcludeMissing fun _audio(): JsonField = audio + + /** + * Returns the raw JSON value of [eventId]. + * + * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId + + @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 + * [RealtimeTranslationInputAudioBufferAppendEvent]. + * + * The following fields are required: + * ```java + * .audio() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RealtimeTranslationInputAudioBufferAppendEvent]. */ + class Builder internal constructor() { + + private var audio: JsonField? = null + private var type: JsonValue = JsonValue.from("session.input_audio_buffer.append") + private var eventId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + realtimeTranslationInputAudioBufferAppendEvent: + RealtimeTranslationInputAudioBufferAppendEvent + ) = apply { + audio = realtimeTranslationInputAudioBufferAppendEvent.audio + type = realtimeTranslationInputAudioBufferAppendEvent.type + eventId = realtimeTranslationInputAudioBufferAppendEvent.eventId + additionalProperties = + realtimeTranslationInputAudioBufferAppendEvent.additionalProperties.toMutableMap() + } + + /** Base64-encoded 24 kHz PCM16 mono audio bytes. */ + fun audio(audio: String) = audio(JsonField.of(audio)) + + /** + * Sets [Builder.audio] to an arbitrary JSON value. + * + * You should usually call [Builder.audio] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun audio(audio: JsonField) = apply { this.audio = audio } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("session.input_audio_buffer.append") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Optional client-generated ID used to identify this event. */ + fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + + /** + * Sets [Builder.eventId] to an arbitrary JSON value. + * + * You should usually call [Builder.eventId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun eventId(eventId: JsonField) = apply { this.eventId = eventId } + + 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 [RealtimeTranslationInputAudioBufferAppendEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .audio() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RealtimeTranslationInputAudioBufferAppendEvent = + RealtimeTranslationInputAudioBufferAppendEvent( + checkRequired("audio", audio), + type, + eventId, + 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(): RealtimeTranslationInputAudioBufferAppendEvent = apply { + if (validated) { + return@apply + } + + audio() + _type().let { + if (it != JsonValue.from("session.input_audio_buffer.append")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + eventId() + 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 (audio.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("session.input_audio_buffer.append")) 1 else 0 } + + (if (eventId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationInputAudioBufferAppendEvent && + audio == other.audio && + type == other.type && + eventId == other.eventId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(audio, type, eventId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RealtimeTranslationInputAudioBufferAppendEvent{audio=$audio, type=$type, eventId=$eventId, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationInputTranscriptDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationInputTranscriptDeltaEvent.kt new file mode 100644 index 000000000..5975ae668 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationInputTranscriptDeltaEvent.kt @@ -0,0 +1,324 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returned when optional source-language transcript text is available. This event is emitted only + * when `audio.input.transcription` is configured. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional spaces + * between deltas. + */ +class RealtimeTranslationInputTranscriptDeltaEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val delta: JsonField, + private val eventId: JsonField, + private val type: JsonValue, + private val elapsedMs: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("delta") @ExcludeMissing delta: JsonField = JsonMissing.of(), + @JsonProperty("event_id") @ExcludeMissing eventId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("elapsed_ms") @ExcludeMissing elapsedMs: JsonField = JsonMissing.of(), + ) : this(delta, eventId, type, elapsedMs, mutableMapOf()) + + /** + * Append-only source-language transcript text. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun delta(): String = delta.getRequired("delta") + + /** + * The unique ID of the server event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventId(): String = eventId.getRequired("event_id") + + /** + * The event type, must be `session.input_transcript.delta`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("session.input_transcript.delta") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Timing metadata for stream alignment, derived from the translation frame when available. It + * advances in 200 ms increments, but multiple transcript deltas may share the same + * `elapsed_ms`. Treat it as alignment metadata, not a unique transcript-delta identifier. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elapsedMs(): Optional = elapsedMs.getOptional("elapsed_ms") + + /** + * Returns the raw JSON value of [delta]. + * + * Unlike [delta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delta") @ExcludeMissing fun _delta(): JsonField = delta + + /** + * Returns the raw JSON value of [eventId]. + * + * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId + + /** + * Returns the raw JSON value of [elapsedMs]. + * + * Unlike [elapsedMs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elapsed_ms") @ExcludeMissing fun _elapsedMs(): JsonField = elapsedMs + + @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 + * [RealtimeTranslationInputTranscriptDeltaEvent]. + * + * The following fields are required: + * ```java + * .delta() + * .eventId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RealtimeTranslationInputTranscriptDeltaEvent]. */ + class Builder internal constructor() { + + private var delta: JsonField? = null + private var eventId: JsonField? = null + private var type: JsonValue = JsonValue.from("session.input_transcript.delta") + private var elapsedMs: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + realtimeTranslationInputTranscriptDeltaEvent: + RealtimeTranslationInputTranscriptDeltaEvent + ) = apply { + delta = realtimeTranslationInputTranscriptDeltaEvent.delta + eventId = realtimeTranslationInputTranscriptDeltaEvent.eventId + type = realtimeTranslationInputTranscriptDeltaEvent.type + elapsedMs = realtimeTranslationInputTranscriptDeltaEvent.elapsedMs + additionalProperties = + realtimeTranslationInputTranscriptDeltaEvent.additionalProperties.toMutableMap() + } + + /** Append-only source-language transcript text. */ + fun delta(delta: String) = delta(JsonField.of(delta)) + + /** + * Sets [Builder.delta] to an arbitrary JSON value. + * + * You should usually call [Builder.delta] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delta(delta: JsonField) = apply { this.delta = delta } + + /** The unique ID of the server event. */ + fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + + /** + * Sets [Builder.eventId] to an arbitrary JSON value. + * + * You should usually call [Builder.eventId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun eventId(eventId: JsonField) = apply { this.eventId = eventId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("session.input_transcript.delta") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Timing metadata for stream alignment, derived from the translation frame when available. + * It advances in 200 ms increments, but multiple transcript deltas may share the same + * `elapsed_ms`. Treat it as alignment metadata, not a unique transcript-delta identifier. + */ + fun elapsedMs(elapsedMs: Long?) = elapsedMs(JsonField.ofNullable(elapsedMs)) + + /** + * Alias for [Builder.elapsedMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun elapsedMs(elapsedMs: Long) = elapsedMs(elapsedMs as Long?) + + /** Alias for calling [Builder.elapsedMs] with `elapsedMs.orElse(null)`. */ + fun elapsedMs(elapsedMs: Optional) = elapsedMs(elapsedMs.getOrNull()) + + /** + * Sets [Builder.elapsedMs] to an arbitrary JSON value. + * + * You should usually call [Builder.elapsedMs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun elapsedMs(elapsedMs: JsonField) = apply { this.elapsedMs = elapsedMs } + + 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 [RealtimeTranslationInputTranscriptDeltaEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .delta() + * .eventId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RealtimeTranslationInputTranscriptDeltaEvent = + RealtimeTranslationInputTranscriptDeltaEvent( + checkRequired("delta", delta), + checkRequired("eventId", eventId), + type, + elapsedMs, + 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(): RealtimeTranslationInputTranscriptDeltaEvent = apply { + if (validated) { + return@apply + } + + delta() + eventId() + _type().let { + if (it != JsonValue.from("session.input_transcript.delta")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + elapsedMs() + 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 (delta.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("session.input_transcript.delta")) 1 else 0 } + + (if (elapsedMs.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationInputTranscriptDeltaEvent && + delta == other.delta && + eventId == other.eventId && + type == other.type && + elapsedMs == other.elapsedMs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(delta, eventId, type, elapsedMs, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RealtimeTranslationInputTranscriptDeltaEvent{delta=$delta, eventId=$eventId, type=$type, elapsedMs=$elapsedMs, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationOutputAudioDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationOutputAudioDeltaEvent.kt new file mode 100644 index 000000000..d2594c146 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationOutputAudioDeltaEvent.kt @@ -0,0 +1,559 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.Enum +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returned when translated output audio is available. Output audio deltas are 200 ms frames of + * PCM16 audio. + */ +class RealtimeTranslationOutputAudioDeltaEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val delta: JsonField, + private val eventId: JsonField, + private val type: JsonValue, + private val channels: JsonField, + private val elapsedMs: JsonField, + private val format: JsonField, + private val sampleRate: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("delta") @ExcludeMissing delta: JsonField = JsonMissing.of(), + @JsonProperty("event_id") @ExcludeMissing eventId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("channels") @ExcludeMissing channels: JsonField = JsonMissing.of(), + @JsonProperty("elapsed_ms") @ExcludeMissing elapsedMs: JsonField = JsonMissing.of(), + @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), + @JsonProperty("sample_rate") @ExcludeMissing sampleRate: JsonField = JsonMissing.of(), + ) : this(delta, eventId, type, channels, elapsedMs, format, sampleRate, mutableMapOf()) + + /** + * Base64-encoded translated audio data. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun delta(): String = delta.getRequired("delta") + + /** + * The unique ID of the server event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventId(): String = eventId.getRequired("event_id") + + /** + * The event type, must be `session.output_audio.delta`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("session.output_audio.delta") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Number of audio channels. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * Timing metadata for stream alignment, derived from the translation frame when available. + * Treat `elapsed_ms` as alignment metadata, not a unique event identifier. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elapsedMs(): Optional = elapsedMs.getOptional("elapsed_ms") + + /** + * Audio encoding for `delta`. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun format(): Optional = format.getOptional("format") + + /** + * Sample rate of the audio delta. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sampleRate(): Optional = sampleRate.getOptional("sample_rate") + + /** + * Returns the raw JSON value of [delta]. + * + * Unlike [delta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delta") @ExcludeMissing fun _delta(): JsonField = delta + + /** + * Returns the raw JSON value of [eventId]. + * + * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [elapsedMs]. + * + * Unlike [elapsedMs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elapsed_ms") @ExcludeMissing fun _elapsedMs(): JsonField = elapsedMs + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [sampleRate]. + * + * Unlike [sampleRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sample_rate") @ExcludeMissing fun _sampleRate(): JsonField = sampleRate + + @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 + * [RealtimeTranslationOutputAudioDeltaEvent]. + * + * The following fields are required: + * ```java + * .delta() + * .eventId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RealtimeTranslationOutputAudioDeltaEvent]. */ + class Builder internal constructor() { + + private var delta: JsonField? = null + private var eventId: JsonField? = null + private var type: JsonValue = JsonValue.from("session.output_audio.delta") + private var channels: JsonField = JsonMissing.of() + private var elapsedMs: JsonField = JsonMissing.of() + private var format: JsonField = JsonMissing.of() + private var sampleRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + realtimeTranslationOutputAudioDeltaEvent: RealtimeTranslationOutputAudioDeltaEvent + ) = apply { + delta = realtimeTranslationOutputAudioDeltaEvent.delta + eventId = realtimeTranslationOutputAudioDeltaEvent.eventId + type = realtimeTranslationOutputAudioDeltaEvent.type + channels = realtimeTranslationOutputAudioDeltaEvent.channels + elapsedMs = realtimeTranslationOutputAudioDeltaEvent.elapsedMs + format = realtimeTranslationOutputAudioDeltaEvent.format + sampleRate = realtimeTranslationOutputAudioDeltaEvent.sampleRate + additionalProperties = + realtimeTranslationOutputAudioDeltaEvent.additionalProperties.toMutableMap() + } + + /** Base64-encoded translated audio data. */ + fun delta(delta: String) = delta(JsonField.of(delta)) + + /** + * Sets [Builder.delta] to an arbitrary JSON value. + * + * You should usually call [Builder.delta] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delta(delta: JsonField) = apply { this.delta = delta } + + /** The unique ID of the server event. */ + fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + + /** + * Sets [Builder.eventId] to an arbitrary JSON value. + * + * You should usually call [Builder.eventId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun eventId(eventId: JsonField) = apply { this.eventId = eventId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("session.output_audio.delta") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Number of audio channels. */ + fun channels(channels: Long) = channels(JsonField.of(channels)) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun channels(channels: JsonField) = apply { this.channels = channels } + + /** + * Timing metadata for stream alignment, derived from the translation frame when available. + * Treat `elapsed_ms` as alignment metadata, not a unique event identifier. + */ + fun elapsedMs(elapsedMs: Long?) = elapsedMs(JsonField.ofNullable(elapsedMs)) + + /** + * Alias for [Builder.elapsedMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun elapsedMs(elapsedMs: Long) = elapsedMs(elapsedMs as Long?) + + /** Alias for calling [Builder.elapsedMs] with `elapsedMs.orElse(null)`. */ + fun elapsedMs(elapsedMs: Optional) = elapsedMs(elapsedMs.getOrNull()) + + /** + * Sets [Builder.elapsedMs] to an arbitrary JSON value. + * + * You should usually call [Builder.elapsedMs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun elapsedMs(elapsedMs: JsonField) = apply { this.elapsedMs = elapsedMs } + + /** Audio encoding for `delta`. */ + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + /** Sample rate of the audio delta. */ + fun sampleRate(sampleRate: Long) = sampleRate(JsonField.of(sampleRate)) + + /** + * Sets [Builder.sampleRate] to an arbitrary JSON value. + * + * You should usually call [Builder.sampleRate] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sampleRate(sampleRate: JsonField) = apply { this.sampleRate = sampleRate } + + 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 [RealtimeTranslationOutputAudioDeltaEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .delta() + * .eventId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RealtimeTranslationOutputAudioDeltaEvent = + RealtimeTranslationOutputAudioDeltaEvent( + checkRequired("delta", delta), + checkRequired("eventId", eventId), + type, + channels, + elapsedMs, + format, + sampleRate, + 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(): RealtimeTranslationOutputAudioDeltaEvent = apply { + if (validated) { + return@apply + } + + delta() + eventId() + _type().let { + if (it != JsonValue.from("session.output_audio.delta")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + channels() + elapsedMs() + format().ifPresent { it.validate() } + sampleRate() + 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 (delta.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("session.output_audio.delta")) 1 else 0 } + + (if (channels.asKnown().isPresent) 1 else 0) + + (if (elapsedMs.asKnown().isPresent) 1 else 0) + + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (sampleRate.asKnown().isPresent) 1 else 0) + + /** Audio encoding for `delta`. */ + class Format @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 PCM16 = of("pcm16") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + PCM16 + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] 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 { + PCM16, + /** An enum member indicating that [Format] 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) { + PCM16 -> Value.PCM16 + 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) { + PCM16 -> Known.PCM16 + else -> throw OpenAIInvalidDataException("Unknown Format: $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(): Format = 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 Format && 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 RealtimeTranslationOutputAudioDeltaEvent && + delta == other.delta && + eventId == other.eventId && + type == other.type && + channels == other.channels && + elapsedMs == other.elapsedMs && + format == other.format && + sampleRate == other.sampleRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + delta, + eventId, + type, + channels, + elapsedMs, + format, + sampleRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RealtimeTranslationOutputAudioDeltaEvent{delta=$delta, eventId=$eventId, type=$type, channels=$channels, elapsedMs=$elapsedMs, format=$format, sampleRate=$sampleRate, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationOutputTranscriptDeltaEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationOutputTranscriptDeltaEvent.kt new file mode 100644 index 000000000..7c33cba83 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationOutputTranscriptDeltaEvent.kt @@ -0,0 +1,323 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Returned when translated transcript text is available. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional spaces + * between deltas. + */ +class RealtimeTranslationOutputTranscriptDeltaEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val delta: JsonField, + private val eventId: JsonField, + private val type: JsonValue, + private val elapsedMs: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("delta") @ExcludeMissing delta: JsonField = JsonMissing.of(), + @JsonProperty("event_id") @ExcludeMissing eventId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("elapsed_ms") @ExcludeMissing elapsedMs: JsonField = JsonMissing.of(), + ) : this(delta, eventId, type, elapsedMs, mutableMapOf()) + + /** + * Append-only transcript text for the translated output audio. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun delta(): String = delta.getRequired("delta") + + /** + * The unique ID of the server event. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun eventId(): String = eventId.getRequired("event_id") + + /** + * The event type, must be `session.output_transcript.delta`. + * + * Expected to always return the following: + * ```java + * JsonValue.from("session.output_transcript.delta") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Timing metadata for stream alignment, derived from the translation frame when available. It + * advances in 200 ms increments, but multiple transcript deltas may share the same + * `elapsed_ms`. Treat it as alignment metadata, not a unique transcript-delta identifier. + * + * @throws OpenAIInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elapsedMs(): Optional = elapsedMs.getOptional("elapsed_ms") + + /** + * Returns the raw JSON value of [delta]. + * + * Unlike [delta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delta") @ExcludeMissing fun _delta(): JsonField = delta + + /** + * Returns the raw JSON value of [eventId]. + * + * Unlike [eventId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId + + /** + * Returns the raw JSON value of [elapsedMs]. + * + * Unlike [elapsedMs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elapsed_ms") @ExcludeMissing fun _elapsedMs(): JsonField = elapsedMs + + @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 + * [RealtimeTranslationOutputTranscriptDeltaEvent]. + * + * The following fields are required: + * ```java + * .delta() + * .eventId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RealtimeTranslationOutputTranscriptDeltaEvent]. */ + class Builder internal constructor() { + + private var delta: JsonField? = null + private var eventId: JsonField? = null + private var type: JsonValue = JsonValue.from("session.output_transcript.delta") + private var elapsedMs: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + realtimeTranslationOutputTranscriptDeltaEvent: + RealtimeTranslationOutputTranscriptDeltaEvent + ) = apply { + delta = realtimeTranslationOutputTranscriptDeltaEvent.delta + eventId = realtimeTranslationOutputTranscriptDeltaEvent.eventId + type = realtimeTranslationOutputTranscriptDeltaEvent.type + elapsedMs = realtimeTranslationOutputTranscriptDeltaEvent.elapsedMs + additionalProperties = + realtimeTranslationOutputTranscriptDeltaEvent.additionalProperties.toMutableMap() + } + + /** Append-only transcript text for the translated output audio. */ + fun delta(delta: String) = delta(JsonField.of(delta)) + + /** + * Sets [Builder.delta] to an arbitrary JSON value. + * + * You should usually call [Builder.delta] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delta(delta: JsonField) = apply { this.delta = delta } + + /** The unique ID of the server event. */ + fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + + /** + * Sets [Builder.eventId] to an arbitrary JSON value. + * + * You should usually call [Builder.eventId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun eventId(eventId: JsonField) = apply { this.eventId = eventId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("session.output_transcript.delta") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Timing metadata for stream alignment, derived from the translation frame when available. + * It advances in 200 ms increments, but multiple transcript deltas may share the same + * `elapsed_ms`. Treat it as alignment metadata, not a unique transcript-delta identifier. + */ + fun elapsedMs(elapsedMs: Long?) = elapsedMs(JsonField.ofNullable(elapsedMs)) + + /** + * Alias for [Builder.elapsedMs]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun elapsedMs(elapsedMs: Long) = elapsedMs(elapsedMs as Long?) + + /** Alias for calling [Builder.elapsedMs] with `elapsedMs.orElse(null)`. */ + fun elapsedMs(elapsedMs: Optional) = elapsedMs(elapsedMs.getOrNull()) + + /** + * Sets [Builder.elapsedMs] to an arbitrary JSON value. + * + * You should usually call [Builder.elapsedMs] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun elapsedMs(elapsedMs: JsonField) = apply { this.elapsedMs = elapsedMs } + + 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 [RealtimeTranslationOutputTranscriptDeltaEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .delta() + * .eventId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RealtimeTranslationOutputTranscriptDeltaEvent = + RealtimeTranslationOutputTranscriptDeltaEvent( + checkRequired("delta", delta), + checkRequired("eventId", eventId), + type, + elapsedMs, + 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(): RealtimeTranslationOutputTranscriptDeltaEvent = apply { + if (validated) { + return@apply + } + + delta() + eventId() + _type().let { + if (it != JsonValue.from("session.output_transcript.delta")) { + throw OpenAIInvalidDataException("'type' is invalid, received $it") + } + } + elapsedMs() + 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 (delta.asKnown().isPresent) 1 else 0) + + (if (eventId.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("session.output_transcript.delta")) 1 else 0 } + + (if (elapsedMs.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationOutputTranscriptDeltaEvent && + delta == other.delta && + eventId == other.eventId && + type == other.type && + elapsedMs == other.elapsedMs && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(delta, eventId, type, elapsedMs, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RealtimeTranslationOutputTranscriptDeltaEvent{delta=$delta, eventId=$eventId, type=$type, elapsedMs=$elapsedMs, additionalProperties=$additionalProperties}" +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationServerEvent.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationServerEvent.kt new file mode 100644 index 000000000..5529dbc87 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationServerEvent.kt @@ -0,0 +1,599 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.openai.core.BaseDeserializer +import com.openai.core.BaseSerializer +import com.openai.core.JsonValue +import com.openai.core.getOrThrow +import com.openai.errors.OpenAIInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A Realtime translation server event. */ +@JsonDeserialize(using = RealtimeTranslationServerEvent.Deserializer::class) +@JsonSerialize(using = RealtimeTranslationServerEvent.Serializer::class) +class RealtimeTranslationServerEvent +private constructor( + private val error: RealtimeErrorEvent? = null, + private val sessionCreated: RealtimeTranslationSessionCreatedEvent? = null, + private val sessionUpdated: RealtimeTranslationSessionUpdatedEvent? = null, + private val sessionClosed: RealtimeTranslationSessionClosedEvent? = null, + private val sessionInputTranscriptDelta: RealtimeTranslationInputTranscriptDeltaEvent? = null, + private val sessionOutputTranscriptDelta: RealtimeTranslationOutputTranscriptDeltaEvent? = null, + private val sessionOutputAudioDelta: RealtimeTranslationOutputAudioDeltaEvent? = null, + private val _json: JsonValue? = null, +) { + + /** + * Returned when an error occurs, which could be a client problem or a server problem. Most + * errors are recoverable and the session will stay open, we recommend to implementors to + * monitor and log error messages by default. + */ + fun error(): Optional = Optional.ofNullable(error) + + /** + * Returned when a translation session is created. Emitted automatically when a new connection + * is established as the first server event. This event contains the default translation session + * configuration. + */ + fun sessionCreated(): Optional = + Optional.ofNullable(sessionCreated) + + /** + * Returned when a translation session is updated with a `session.update` event, unless there is + * an error. + */ + fun sessionUpdated(): Optional = + Optional.ofNullable(sessionUpdated) + + /** Returned when a realtime translation session is closed. */ + fun sessionClosed(): Optional = + Optional.ofNullable(sessionClosed) + + /** + * Returned when optional source-language transcript text is available. This event is emitted + * only when `audio.input.transcription` is configured. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + fun sessionInputTranscriptDelta(): Optional = + Optional.ofNullable(sessionInputTranscriptDelta) + + /** + * Returned when translated transcript text is available. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + fun sessionOutputTranscriptDelta(): Optional = + Optional.ofNullable(sessionOutputTranscriptDelta) + + /** + * Returned when translated output audio is available. Output audio deltas are 200 ms frames of + * PCM16 audio. + */ + fun sessionOutputAudioDelta(): Optional = + Optional.ofNullable(sessionOutputAudioDelta) + + fun isError(): Boolean = error != null + + fun isSessionCreated(): Boolean = sessionCreated != null + + fun isSessionUpdated(): Boolean = sessionUpdated != null + + fun isSessionClosed(): Boolean = sessionClosed != null + + fun isSessionInputTranscriptDelta(): Boolean = sessionInputTranscriptDelta != null + + fun isSessionOutputTranscriptDelta(): Boolean = sessionOutputTranscriptDelta != null + + fun isSessionOutputAudioDelta(): Boolean = sessionOutputAudioDelta != null + + /** + * Returned when an error occurs, which could be a client problem or a server problem. Most + * errors are recoverable and the session will stay open, we recommend to implementors to + * monitor and log error messages by default. + */ + fun asError(): RealtimeErrorEvent = error.getOrThrow("error") + + /** + * Returned when a translation session is created. Emitted automatically when a new connection + * is established as the first server event. This event contains the default translation session + * configuration. + */ + fun asSessionCreated(): RealtimeTranslationSessionCreatedEvent = + sessionCreated.getOrThrow("sessionCreated") + + /** + * Returned when a translation session is updated with a `session.update` event, unless there is + * an error. + */ + fun asSessionUpdated(): RealtimeTranslationSessionUpdatedEvent = + sessionUpdated.getOrThrow("sessionUpdated") + + /** Returned when a realtime translation session is closed. */ + fun asSessionClosed(): RealtimeTranslationSessionClosedEvent = + sessionClosed.getOrThrow("sessionClosed") + + /** + * Returned when optional source-language transcript text is available. This event is emitted + * only when `audio.input.transcription` is configured. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + fun asSessionInputTranscriptDelta(): RealtimeTranslationInputTranscriptDeltaEvent = + sessionInputTranscriptDelta.getOrThrow("sessionInputTranscriptDelta") + + /** + * Returned when translated transcript text is available. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + fun asSessionOutputTranscriptDelta(): RealtimeTranslationOutputTranscriptDeltaEvent = + sessionOutputTranscriptDelta.getOrThrow("sessionOutputTranscriptDelta") + + /** + * Returned when translated output audio is available. Output audio deltas are 200 ms frames of + * PCM16 audio. + */ + fun asSessionOutputAudioDelta(): RealtimeTranslationOutputAudioDeltaEvent = + sessionOutputAudioDelta.getOrThrow("sessionOutputAudioDelta") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.openai.core.JsonValue; + * import java.util.Optional; + * + * Optional result = realtimeTranslationServerEvent.accept(new RealtimeTranslationServerEvent.Visitor>() { + * @Override + * public Optional visitError(RealtimeErrorEvent error) { + * return Optional.of(error.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws OpenAIInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + error != null -> visitor.visitError(error) + sessionCreated != null -> visitor.visitSessionCreated(sessionCreated) + sessionUpdated != null -> visitor.visitSessionUpdated(sessionUpdated) + sessionClosed != null -> visitor.visitSessionClosed(sessionClosed) + sessionInputTranscriptDelta != null -> + visitor.visitSessionInputTranscriptDelta(sessionInputTranscriptDelta) + sessionOutputTranscriptDelta != null -> + visitor.visitSessionOutputTranscriptDelta(sessionOutputTranscriptDelta) + sessionOutputAudioDelta != null -> + visitor.visitSessionOutputAudioDelta(sessionOutputAudioDelta) + else -> visitor.unknown(_json) + } + + 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(): RealtimeTranslationServerEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitError(error: RealtimeErrorEvent) { + error.validate() + } + + override fun visitSessionCreated( + sessionCreated: RealtimeTranslationSessionCreatedEvent + ) { + sessionCreated.validate() + } + + override fun visitSessionUpdated( + sessionUpdated: RealtimeTranslationSessionUpdatedEvent + ) { + sessionUpdated.validate() + } + + override fun visitSessionClosed( + sessionClosed: RealtimeTranslationSessionClosedEvent + ) { + sessionClosed.validate() + } + + override fun visitSessionInputTranscriptDelta( + sessionInputTranscriptDelta: RealtimeTranslationInputTranscriptDeltaEvent + ) { + sessionInputTranscriptDelta.validate() + } + + override fun visitSessionOutputTranscriptDelta( + sessionOutputTranscriptDelta: RealtimeTranslationOutputTranscriptDeltaEvent + ) { + sessionOutputTranscriptDelta.validate() + } + + override fun visitSessionOutputAudioDelta( + sessionOutputAudioDelta: RealtimeTranslationOutputAudioDeltaEvent + ) { + sessionOutputAudioDelta.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: OpenAIInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitError(error: RealtimeErrorEvent) = error.validity() + + override fun visitSessionCreated( + sessionCreated: RealtimeTranslationSessionCreatedEvent + ) = sessionCreated.validity() + + override fun visitSessionUpdated( + sessionUpdated: RealtimeTranslationSessionUpdatedEvent + ) = sessionUpdated.validity() + + override fun visitSessionClosed( + sessionClosed: RealtimeTranslationSessionClosedEvent + ) = sessionClosed.validity() + + override fun visitSessionInputTranscriptDelta( + sessionInputTranscriptDelta: RealtimeTranslationInputTranscriptDeltaEvent + ) = sessionInputTranscriptDelta.validity() + + override fun visitSessionOutputTranscriptDelta( + sessionOutputTranscriptDelta: RealtimeTranslationOutputTranscriptDeltaEvent + ) = sessionOutputTranscriptDelta.validity() + + override fun visitSessionOutputAudioDelta( + sessionOutputAudioDelta: RealtimeTranslationOutputAudioDeltaEvent + ) = sessionOutputAudioDelta.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RealtimeTranslationServerEvent && + error == other.error && + sessionCreated == other.sessionCreated && + sessionUpdated == other.sessionUpdated && + sessionClosed == other.sessionClosed && + sessionInputTranscriptDelta == other.sessionInputTranscriptDelta && + sessionOutputTranscriptDelta == other.sessionOutputTranscriptDelta && + sessionOutputAudioDelta == other.sessionOutputAudioDelta + } + + override fun hashCode(): Int = + Objects.hash( + error, + sessionCreated, + sessionUpdated, + sessionClosed, + sessionInputTranscriptDelta, + sessionOutputTranscriptDelta, + sessionOutputAudioDelta, + ) + + override fun toString(): String = + when { + error != null -> "RealtimeTranslationServerEvent{error=$error}" + sessionCreated != null -> + "RealtimeTranslationServerEvent{sessionCreated=$sessionCreated}" + sessionUpdated != null -> + "RealtimeTranslationServerEvent{sessionUpdated=$sessionUpdated}" + sessionClosed != null -> "RealtimeTranslationServerEvent{sessionClosed=$sessionClosed}" + sessionInputTranscriptDelta != null -> + "RealtimeTranslationServerEvent{sessionInputTranscriptDelta=$sessionInputTranscriptDelta}" + sessionOutputTranscriptDelta != null -> + "RealtimeTranslationServerEvent{sessionOutputTranscriptDelta=$sessionOutputTranscriptDelta}" + sessionOutputAudioDelta != null -> + "RealtimeTranslationServerEvent{sessionOutputAudioDelta=$sessionOutputAudioDelta}" + _json != null -> "RealtimeTranslationServerEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid RealtimeTranslationServerEvent") + } + + companion object { + + /** + * Returned when an error occurs, which could be a client problem or a server problem. Most + * errors are recoverable and the session will stay open, we recommend to implementors to + * monitor and log error messages by default. + */ + @JvmStatic + fun ofError(error: RealtimeErrorEvent) = RealtimeTranslationServerEvent(error = error) + + /** + * Returned when a translation session is created. Emitted automatically when a new + * connection is established as the first server event. This event contains the default + * translation session configuration. + */ + @JvmStatic + fun ofSessionCreated(sessionCreated: RealtimeTranslationSessionCreatedEvent) = + RealtimeTranslationServerEvent(sessionCreated = sessionCreated) + + /** + * Returned when a translation session is updated with a `session.update` event, unless + * there is an error. + */ + @JvmStatic + fun ofSessionUpdated(sessionUpdated: RealtimeTranslationSessionUpdatedEvent) = + RealtimeTranslationServerEvent(sessionUpdated = sessionUpdated) + + /** Returned when a realtime translation session is closed. */ + @JvmStatic + fun ofSessionClosed(sessionClosed: RealtimeTranslationSessionClosedEvent) = + RealtimeTranslationServerEvent(sessionClosed = sessionClosed) + + /** + * Returned when optional source-language transcript text is available. This event is + * emitted only when `audio.input.transcription` is configured. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + @JvmStatic + fun ofSessionInputTranscriptDelta( + sessionInputTranscriptDelta: RealtimeTranslationInputTranscriptDeltaEvent + ) = + RealtimeTranslationServerEvent( + sessionInputTranscriptDelta = sessionInputTranscriptDelta + ) + + /** + * Returned when translated transcript text is available. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + @JvmStatic + fun ofSessionOutputTranscriptDelta( + sessionOutputTranscriptDelta: RealtimeTranslationOutputTranscriptDeltaEvent + ) = + RealtimeTranslationServerEvent( + sessionOutputTranscriptDelta = sessionOutputTranscriptDelta + ) + + /** + * Returned when translated output audio is available. Output audio deltas are 200 ms frames + * of PCM16 audio. + */ + @JvmStatic + fun ofSessionOutputAudioDelta( + sessionOutputAudioDelta: RealtimeTranslationOutputAudioDeltaEvent + ) = RealtimeTranslationServerEvent(sessionOutputAudioDelta = sessionOutputAudioDelta) + } + + /** + * An interface that defines how to map each variant of [RealtimeTranslationServerEvent] to a + * value of type [T]. + */ + interface Visitor { + + /** + * Returned when an error occurs, which could be a client problem or a server problem. Most + * errors are recoverable and the session will stay open, we recommend to implementors to + * monitor and log error messages by default. + */ + fun visitError(error: RealtimeErrorEvent): T + + /** + * Returned when a translation session is created. Emitted automatically when a new + * connection is established as the first server event. This event contains the default + * translation session configuration. + */ + fun visitSessionCreated(sessionCreated: RealtimeTranslationSessionCreatedEvent): T + + /** + * Returned when a translation session is updated with a `session.update` event, unless + * there is an error. + */ + fun visitSessionUpdated(sessionUpdated: RealtimeTranslationSessionUpdatedEvent): T + + /** Returned when a realtime translation session is closed. */ + fun visitSessionClosed(sessionClosed: RealtimeTranslationSessionClosedEvent): T + + /** + * Returned when optional source-language transcript text is available. This event is + * emitted only when `audio.input.transcription` is configured. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + fun visitSessionInputTranscriptDelta( + sessionInputTranscriptDelta: RealtimeTranslationInputTranscriptDeltaEvent + ): T + + /** + * Returned when translated transcript text is available. + * + * Transcript deltas are append-only text fragments. Clients should not insert unconditional + * spaces between deltas. + */ + fun visitSessionOutputTranscriptDelta( + sessionOutputTranscriptDelta: RealtimeTranslationOutputTranscriptDeltaEvent + ): T + + /** + * Returned when translated output audio is available. Output audio deltas are 200 ms frames + * of PCM16 audio. + */ + fun visitSessionOutputAudioDelta( + sessionOutputAudioDelta: RealtimeTranslationOutputAudioDeltaEvent + ): T + + /** + * Maps an unknown variant of [RealtimeTranslationServerEvent] to a value of type [T]. + * + * An instance of [RealtimeTranslationServerEvent] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws OpenAIInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw OpenAIInvalidDataException("Unknown RealtimeTranslationServerEvent: $json") + } + } + + internal class Deserializer : + BaseDeserializer(RealtimeTranslationServerEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): RealtimeTranslationServerEvent { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "error" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + RealtimeTranslationServerEvent(error = it, _json = json) + } ?: RealtimeTranslationServerEvent(_json = json) + } + "session.created" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RealtimeTranslationServerEvent(sessionCreated = it, _json = json) } + ?: RealtimeTranslationServerEvent(_json = json) + } + "session.updated" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RealtimeTranslationServerEvent(sessionUpdated = it, _json = json) } + ?: RealtimeTranslationServerEvent(_json = json) + } + "session.closed" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { RealtimeTranslationServerEvent(sessionClosed = it, _json = json) } + ?: RealtimeTranslationServerEvent(_json = json) + } + "session.input_transcript.delta" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + RealtimeTranslationServerEvent( + sessionInputTranscriptDelta = it, + _json = json, + ) + } ?: RealtimeTranslationServerEvent(_json = json) + } + "session.output_transcript.delta" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + RealtimeTranslationServerEvent( + sessionOutputTranscriptDelta = it, + _json = json, + ) + } ?: RealtimeTranslationServerEvent(_json = json) + } + "session.output_audio.delta" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + RealtimeTranslationServerEvent( + sessionOutputAudioDelta = it, + _json = json, + ) + } ?: RealtimeTranslationServerEvent(_json = json) + } + } + + return RealtimeTranslationServerEvent(_json = json) + } + } + + internal class Serializer : + BaseSerializer(RealtimeTranslationServerEvent::class) { + + override fun serialize( + value: RealtimeTranslationServerEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.error != null -> generator.writeObject(value.error) + value.sessionCreated != null -> generator.writeObject(value.sessionCreated) + value.sessionUpdated != null -> generator.writeObject(value.sessionUpdated) + value.sessionClosed != null -> generator.writeObject(value.sessionClosed) + value.sessionInputTranscriptDelta != null -> + generator.writeObject(value.sessionInputTranscriptDelta) + value.sessionOutputTranscriptDelta != null -> + generator.writeObject(value.sessionOutputTranscriptDelta) + value.sessionOutputAudioDelta != null -> + generator.writeObject(value.sessionOutputAudioDelta) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid RealtimeTranslationServerEvent") + } + } + } +} diff --git a/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationSession.kt b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationSession.kt new file mode 100644 index 000000000..2fe613857 --- /dev/null +++ b/openai-java-core/src/main/kotlin/com/openai/models/realtime/RealtimeTranslationSession.kt @@ -0,0 +1,1276 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openai.models.realtime + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.openai.core.ExcludeMissing +import com.openai.core.JsonField +import com.openai.core.JsonMissing +import com.openai.core.JsonValue +import com.openai.core.checkRequired +import com.openai.errors.OpenAIInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A Realtime translation session. Translation sessions continuously translate input audio into the + * configured output language. + */ +class RealtimeTranslationSession +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val audio: JsonField