diff --git a/.stats.yml b/.stats.yml index 2737fad..93f240e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 138 +configured_endpoints: 144 diff --git a/CHANGELOG.md b/CHANGELOG.md index a518a90..94bf0a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,17 +1,5 @@ # Changelog -## [1.7.0](https://github.com/run-llama/llama-parse-java/compare/v1.6.0...v1.7.0) (2026-09-08) - - -### ⚠ BREAKING CHANGES - -* **classifier:** the classify v1 job methods (`client.classifier().jobs().create()`, `.list()`, `.get()`, `.getResults()`) are removed. The `/api/v1/classifier/jobs*` routes were unpublished from the API surface; use `client.classify()` instead. - - -### Features - -* **api:** map DELETE /api/v2/parse/{job_id} and GET /api/v2/pipelines into the SDKs (LI-9569) ([79761cc](https://github.com/run-llama/llama-parse-java/commit/79761cc5fd9ca377298a80911b761d84b6438cc8)) - ## [1.6.0](https://github.com/run-llama/llama-parse-java/compare/v1.5.1...v1.6.0) (2026-08-28) diff --git a/README.md b/README.md index 1ce8c17..9092cb4 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Maven Central](https://img.shields.io/maven-central/v/ai.llamaindex.llamacloud/llama-cloud)](https://central.sonatype.com/artifact/ai.llamaindex.llamacloud/llama-cloud/1.7.0) -[![javadoc](https://javadoc.io/badge2/ai.llamaindex.llamacloud/llama-cloud/1.7.0/javadoc.svg)](https://javadoc.io/doc/ai.llamaindex.llamacloud/llama-cloud/1.6.0) +[![javadoc](https://javadoc.io/badge2/ai.llamaindex.llamacloud/llama-cloud/1.7.0/javadoc.svg)](https://javadoc.io/doc/ai.llamaindex.llamacloud/llama-cloud/1.7.0) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClient.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClient.kt index 529b30f..1a592df 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClient.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClient.kt @@ -11,8 +11,8 @@ import ai.llamaindex.llamacloud.services.blocking.ConfigurationService import ai.llamaindex.llamacloud.services.blocking.DataSinkService import ai.llamaindex.llamacloud.services.blocking.DataSourceService import ai.llamaindex.llamacloud.services.blocking.ExtractService +import ai.llamaindex.llamacloud.services.blocking.ExtractionAgentService import ai.llamaindex.llamacloud.services.blocking.FileService -import ai.llamaindex.llamacloud.services.blocking.JobDataPointService import ai.llamaindex.llamacloud.services.blocking.ParsingService import ai.llamaindex.llamacloud.services.blocking.PipelineService import ai.llamaindex.llamacloud.services.blocking.ProjectService @@ -80,10 +80,10 @@ interface LlamaCloudClient { fun v2Projects(): V2ProjectService - fun jobDataPoints(): JobDataPointService - fun dataSinks(): DataSinkService + fun extractionAgents(): ExtractionAgentService + fun dataSources(): DataSourceService fun pipelines(): PipelineService @@ -137,10 +137,10 @@ interface LlamaCloudClient { fun v2Projects(): V2ProjectService.WithRawResponse - fun jobDataPoints(): JobDataPointService.WithRawResponse - fun dataSinks(): DataSinkService.WithRawResponse + fun extractionAgents(): ExtractionAgentService.WithRawResponse + fun dataSources(): DataSourceService.WithRawResponse fun pipelines(): PipelineService.WithRawResponse diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsync.kt index 3089c92..8c3dea6 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsync.kt @@ -11,8 +11,8 @@ import ai.llamaindex.llamacloud.services.async.ConfigurationServiceAsync import ai.llamaindex.llamacloud.services.async.DataSinkServiceAsync import ai.llamaindex.llamacloud.services.async.DataSourceServiceAsync import ai.llamaindex.llamacloud.services.async.ExtractServiceAsync +import ai.llamaindex.llamacloud.services.async.ExtractionAgentServiceAsync import ai.llamaindex.llamacloud.services.async.FileServiceAsync -import ai.llamaindex.llamacloud.services.async.JobDataPointServiceAsync import ai.llamaindex.llamacloud.services.async.ParsingServiceAsync import ai.llamaindex.llamacloud.services.async.PipelineServiceAsync import ai.llamaindex.llamacloud.services.async.ProjectServiceAsync @@ -80,10 +80,10 @@ interface LlamaCloudClientAsync { fun v2Projects(): V2ProjectServiceAsync - fun jobDataPoints(): JobDataPointServiceAsync - fun dataSinks(): DataSinkServiceAsync + fun extractionAgents(): ExtractionAgentServiceAsync + fun dataSources(): DataSourceServiceAsync fun pipelines(): PipelineServiceAsync @@ -141,10 +141,10 @@ interface LlamaCloudClientAsync { fun v2Projects(): V2ProjectServiceAsync.WithRawResponse - fun jobDataPoints(): JobDataPointServiceAsync.WithRawResponse - fun dataSinks(): DataSinkServiceAsync.WithRawResponse + fun extractionAgents(): ExtractionAgentServiceAsync.WithRawResponse + fun dataSources(): DataSourceServiceAsync.WithRawResponse fun pipelines(): PipelineServiceAsync.WithRawResponse diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsyncImpl.kt index ffb71a2..aa24ea6 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientAsyncImpl.kt @@ -20,10 +20,10 @@ import ai.llamaindex.llamacloud.services.async.DataSourceServiceAsync import ai.llamaindex.llamacloud.services.async.DataSourceServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.ExtractServiceAsync import ai.llamaindex.llamacloud.services.async.ExtractServiceAsyncImpl +import ai.llamaindex.llamacloud.services.async.ExtractionAgentServiceAsync +import ai.llamaindex.llamacloud.services.async.ExtractionAgentServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.FileServiceAsync import ai.llamaindex.llamacloud.services.async.FileServiceAsyncImpl -import ai.llamaindex.llamacloud.services.async.JobDataPointServiceAsync -import ai.llamaindex.llamacloud.services.async.JobDataPointServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.ParsingServiceAsync import ai.llamaindex.llamacloud.services.async.ParsingServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.PipelineServiceAsync @@ -99,14 +99,14 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam V2ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } - private val jobDataPoints: JobDataPointServiceAsync by lazy { - JobDataPointServiceAsyncImpl(clientOptionsWithUserAgent) - } - private val dataSinks: DataSinkServiceAsync by lazy { DataSinkServiceAsyncImpl(clientOptionsWithUserAgent) } + private val extractionAgents: ExtractionAgentServiceAsync by lazy { + ExtractionAgentServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val dataSources: DataSourceServiceAsync by lazy { DataSourceServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -150,10 +150,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun v2Projects(): V2ProjectServiceAsync = v2Projects - override fun jobDataPoints(): JobDataPointServiceAsync = jobDataPoints - override fun dataSinks(): DataSinkServiceAsync = dataSinks + override fun extractionAgents(): ExtractionAgentServiceAsync = extractionAgents + override fun dataSources(): DataSourceServiceAsync = dataSources override fun pipelines(): PipelineServiceAsync = pipelines @@ -211,14 +211,14 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam V2ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val jobDataPoints: JobDataPointServiceAsync.WithRawResponse by lazy { - JobDataPointServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - private val dataSinks: DataSinkServiceAsync.WithRawResponse by lazy { DataSinkServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val extractionAgents: ExtractionAgentServiceAsync.WithRawResponse by lazy { + ExtractionAgentServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val dataSources: DataSourceServiceAsync.WithRawResponse by lazy { DataSourceServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -264,10 +264,11 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun v2Projects(): V2ProjectServiceAsync.WithRawResponse = v2Projects - override fun jobDataPoints(): JobDataPointServiceAsync.WithRawResponse = jobDataPoints - override fun dataSinks(): DataSinkServiceAsync.WithRawResponse = dataSinks + override fun extractionAgents(): ExtractionAgentServiceAsync.WithRawResponse = + extractionAgents + override fun dataSources(): DataSourceServiceAsync.WithRawResponse = dataSources override fun pipelines(): PipelineServiceAsync.WithRawResponse = pipelines diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientImpl.kt index f452787..b9e8526 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/client/LlamaCloudClientImpl.kt @@ -20,10 +20,10 @@ import ai.llamaindex.llamacloud.services.blocking.DataSourceService import ai.llamaindex.llamacloud.services.blocking.DataSourceServiceImpl import ai.llamaindex.llamacloud.services.blocking.ExtractService import ai.llamaindex.llamacloud.services.blocking.ExtractServiceImpl +import ai.llamaindex.llamacloud.services.blocking.ExtractionAgentService +import ai.llamaindex.llamacloud.services.blocking.ExtractionAgentServiceImpl import ai.llamaindex.llamacloud.services.blocking.FileService import ai.llamaindex.llamacloud.services.blocking.FileServiceImpl -import ai.llamaindex.llamacloud.services.blocking.JobDataPointService -import ai.llamaindex.llamacloud.services.blocking.JobDataPointServiceImpl import ai.llamaindex.llamacloud.services.blocking.ParsingService import ai.llamaindex.llamacloud.services.blocking.ParsingServiceImpl import ai.llamaindex.llamacloud.services.blocking.PipelineService @@ -89,14 +89,14 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou V2ProjectServiceImpl(clientOptionsWithUserAgent) } - private val jobDataPoints: JobDataPointService by lazy { - JobDataPointServiceImpl(clientOptionsWithUserAgent) - } - private val dataSinks: DataSinkService by lazy { DataSinkServiceImpl(clientOptionsWithUserAgent) } + private val extractionAgents: ExtractionAgentService by lazy { + ExtractionAgentServiceImpl(clientOptionsWithUserAgent) + } + private val dataSources: DataSourceService by lazy { DataSourceServiceImpl(clientOptionsWithUserAgent) } @@ -140,10 +140,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun v2Projects(): V2ProjectService = v2Projects - override fun jobDataPoints(): JobDataPointService = jobDataPoints - override fun dataSinks(): DataSinkService = dataSinks + override fun extractionAgents(): ExtractionAgentService = extractionAgents + override fun dataSources(): DataSourceService = dataSources override fun pipelines(): PipelineService = pipelines @@ -201,14 +201,14 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou V2ProjectServiceImpl.WithRawResponseImpl(clientOptions) } - private val jobDataPoints: JobDataPointService.WithRawResponse by lazy { - JobDataPointServiceImpl.WithRawResponseImpl(clientOptions) - } - private val dataSinks: DataSinkService.WithRawResponse by lazy { DataSinkServiceImpl.WithRawResponseImpl(clientOptions) } + private val extractionAgents: ExtractionAgentService.WithRawResponse by lazy { + ExtractionAgentServiceImpl.WithRawResponseImpl(clientOptions) + } + private val dataSources: DataSourceService.WithRawResponse by lazy { DataSourceServiceImpl.WithRawResponseImpl(clientOptions) } @@ -254,10 +254,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun v2Projects(): V2ProjectService.WithRawResponse = v2Projects - override fun jobDataPoints(): JobDataPointService.WithRawResponse = jobDataPoints - override fun dataSinks(): DataSinkService.WithRawResponse = dataSinks + override fun extractionAgents(): ExtractionAgentService.WithRawResponse = extractionAgents + override fun dataSources(): DataSourceService.WithRawResponse = dataSources override fun pipelines(): PipelineService.WithRawResponse = pipelines diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentGetParams.kt new file mode 100644 index 0000000..828b65e --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentGetParams.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.beta.attachments + +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Return a presigned download URL for a specific attachment. */ +class AttachmentGetParams +private constructor( + private val attachmentName: String?, + private val sourceId: String, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun attachmentName(): Optional = Optional.ofNullable(attachmentName) + + /** File UUID or directory file ID (dfl-...). */ + fun sourceId(): String = sourceId + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AttachmentGetParams]. + * + * The following fields are required: + * ```java + * .sourceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentGetParams]. */ + class Builder internal constructor() { + + private var attachmentName: String? = null + private var sourceId: String? = null + private var organizationId: String? = null + private var projectId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(attachmentGetParams: AttachmentGetParams) = apply { + attachmentName = attachmentGetParams.attachmentName + sourceId = attachmentGetParams.sourceId + organizationId = attachmentGetParams.organizationId + projectId = attachmentGetParams.projectId + additionalHeaders = attachmentGetParams.additionalHeaders.toBuilder() + additionalQueryParams = attachmentGetParams.additionalQueryParams.toBuilder() + } + + fun attachmentName(attachmentName: String?) = apply { this.attachmentName = attachmentName } + + /** Alias for calling [Builder.attachmentName] with `attachmentName.orElse(null)`. */ + fun attachmentName(attachmentName: Optional) = + attachmentName(attachmentName.getOrNull()) + + /** File UUID or directory file ID (dfl-...). */ + fun sourceId(sourceId: String) = apply { this.sourceId = sourceId } + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AttachmentGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentGetParams = + AttachmentGetParams( + attachmentName, + checkRequired("sourceId", sourceId), + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> attachmentName ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("source_id", sourceId) + organizationId?.let { put("organization_id", it) } + projectId?.let { put("project_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentGetParams && + attachmentName == other.attachmentName && + sourceId == other.sourceId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + attachmentName, + sourceId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "AttachmentGetParams{attachmentName=$attachmentName, sourceId=$sourceId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPage.kt similarity index 54% rename from llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPage.kt rename to llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPage.kt index 78eb924..b567549 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPage.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPage.kt @@ -1,63 +1,63 @@ // File generated from our OpenAPI spec by Stainless. -package ai.llamaindex.llamacloud.models.jobdatapoints +package ai.llamaindex.llamacloud.models.beta.attachments import ai.llamaindex.llamacloud.core.AutoPager import ai.llamaindex.llamacloud.core.Page import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.blocking.JobDataPointService +import ai.llamaindex.llamacloud.services.blocking.beta.AttachmentService import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** @see JobDataPointService.list */ -class JobDataPointListPage +/** @see AttachmentService.list */ +class AttachmentListPage private constructor( - private val service: JobDataPointService, - private val params: JobDataPointListParams, - private val response: JobDataPointListPageResponse, -) : Page { + private val service: AttachmentService, + private val params: AttachmentListParams, + private val response: AttachmentListPageResponse, +) : Page { /** - * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * Delegates to [AttachmentListPageResponse], but gracefully handles missing data. * - * @see JobDataPointListPageResponse.items + * @see AttachmentListPageResponse.items */ - override fun items(): List = + override fun items(): List = response._items().getOptional("items").getOrNull() ?: emptyList() /** - * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * Delegates to [AttachmentListPageResponse], but gracefully handles missing data. * - * @see JobDataPointListPageResponse.nextPageToken + * @see AttachmentListPageResponse.nextPageToken */ fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent - fun nextPageParams(): JobDataPointListParams { + fun nextPageParams(): AttachmentListParams { val nextCursor = nextPageToken().getOrNull() ?: throw IllegalStateException("Cannot construct next page params") return params.toBuilder().pageToken(nextCursor).build() } - override fun nextPage(): JobDataPointListPage = service.list(nextPageParams()) + override fun nextPage(): AttachmentListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ - fun params(): JobDataPointListParams = params + fun params(): AttachmentListParams = params /** The response that this page was parsed from. */ - fun response(): JobDataPointListPageResponse = response + fun response(): AttachmentListPageResponse = response fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [JobDataPointListPage]. + * Returns a mutable builder for constructing an instance of [AttachmentListPage]. * * The following fields are required: * ```java @@ -69,30 +69,30 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [JobDataPointListPage]. */ + /** A builder for [AttachmentListPage]. */ class Builder internal constructor() { - private var service: JobDataPointService? = null - private var params: JobDataPointListParams? = null - private var response: JobDataPointListPageResponse? = null + private var service: AttachmentService? = null + private var params: AttachmentListParams? = null + private var response: AttachmentListPageResponse? = null @JvmSynthetic - internal fun from(jobDataPointListPage: JobDataPointListPage) = apply { - service = jobDataPointListPage.service - params = jobDataPointListPage.params - response = jobDataPointListPage.response + internal fun from(attachmentListPage: AttachmentListPage) = apply { + service = attachmentListPage.service + params = attachmentListPage.params + response = attachmentListPage.response } - fun service(service: JobDataPointService) = apply { this.service = service } + fun service(service: AttachmentService) = apply { this.service = service } /** The parameters that were used to request this page. */ - fun params(params: JobDataPointListParams) = apply { this.params = params } + fun params(params: AttachmentListParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun response(response: JobDataPointListPageResponse) = apply { this.response = response } + fun response(response: AttachmentListPageResponse) = apply { this.response = response } /** - * Returns an immutable instance of [JobDataPointListPage]. + * Returns an immutable instance of [AttachmentListPage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -105,8 +105,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): JobDataPointListPage = - JobDataPointListPage( + fun build(): AttachmentListPage = + AttachmentListPage( checkRequired("service", service), checkRequired("params", params), checkRequired("response", response), @@ -118,7 +118,7 @@ private constructor( return true } - return other is JobDataPointListPage && + return other is AttachmentListPage && service == other.service && params == other.params && response == other.response @@ -127,5 +127,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(service, params, response) override fun toString() = - "JobDataPointListPage{service=$service, params=$params, response=$response}" + "AttachmentListPage{service=$service, params=$params, response=$response}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPageAsync.kt similarity index 57% rename from llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageAsync.kt rename to llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPageAsync.kt index 75e78d3..bc6ea61 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPageAsync.kt @@ -1,67 +1,68 @@ // File generated from our OpenAPI spec by Stainless. -package ai.llamaindex.llamacloud.models.jobdatapoints +package ai.llamaindex.llamacloud.models.beta.attachments import ai.llamaindex.llamacloud.core.AutoPagerAsync import ai.llamaindex.llamacloud.core.PageAsync import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.async.JobDataPointServiceAsync +import ai.llamaindex.llamacloud.services.async.beta.AttachmentServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import kotlin.jvm.optionals.getOrNull -/** @see JobDataPointServiceAsync.list */ -class JobDataPointListPageAsync +/** @see AttachmentServiceAsync.list */ +class AttachmentListPageAsync private constructor( - private val service: JobDataPointServiceAsync, + private val service: AttachmentServiceAsync, private val streamHandlerExecutor: Executor, - private val params: JobDataPointListParams, - private val response: JobDataPointListPageResponse, -) : PageAsync { + private val params: AttachmentListParams, + private val response: AttachmentListPageResponse, +) : PageAsync { /** - * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * Delegates to [AttachmentListPageResponse], but gracefully handles missing data. * - * @see JobDataPointListPageResponse.items + * @see AttachmentListPageResponse.items */ - override fun items(): List = + override fun items(): List = response._items().getOptional("items").getOrNull() ?: emptyList() /** - * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * Delegates to [AttachmentListPageResponse], but gracefully handles missing data. * - * @see JobDataPointListPageResponse.nextPageToken + * @see AttachmentListPageResponse.nextPageToken */ fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent - fun nextPageParams(): JobDataPointListParams { + fun nextPageParams(): AttachmentListParams { val nextCursor = nextPageToken().getOrNull() ?: throw IllegalStateException("Cannot construct next page params") return params.toBuilder().pageToken(nextCursor).build() } - override fun nextPage(): CompletableFuture = + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ - fun params(): JobDataPointListParams = params + fun params(): AttachmentListParams = params /** The response that this page was parsed from. */ - fun response(): JobDataPointListPageResponse = response + fun response(): AttachmentListPageResponse = response fun toBuilder() = Builder().from(this) companion object { /** - * Returns a mutable builder for constructing an instance of [JobDataPointListPageAsync]. + * Returns a mutable builder for constructing an instance of [AttachmentListPageAsync]. * * The following fields are required: * ```java @@ -74,36 +75,36 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [JobDataPointListPageAsync]. */ + /** A builder for [AttachmentListPageAsync]. */ class Builder internal constructor() { - private var service: JobDataPointServiceAsync? = null + private var service: AttachmentServiceAsync? = null private var streamHandlerExecutor: Executor? = null - private var params: JobDataPointListParams? = null - private var response: JobDataPointListPageResponse? = null + private var params: AttachmentListParams? = null + private var response: AttachmentListPageResponse? = null @JvmSynthetic - internal fun from(jobDataPointListPageAsync: JobDataPointListPageAsync) = apply { - service = jobDataPointListPageAsync.service - streamHandlerExecutor = jobDataPointListPageAsync.streamHandlerExecutor - params = jobDataPointListPageAsync.params - response = jobDataPointListPageAsync.response + internal fun from(attachmentListPageAsync: AttachmentListPageAsync) = apply { + service = attachmentListPageAsync.service + streamHandlerExecutor = attachmentListPageAsync.streamHandlerExecutor + params = attachmentListPageAsync.params + response = attachmentListPageAsync.response } - fun service(service: JobDataPointServiceAsync) = apply { this.service = service } + fun service(service: AttachmentServiceAsync) = apply { this.service = service } fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { this.streamHandlerExecutor = streamHandlerExecutor } /** The parameters that were used to request this page. */ - fun params(params: JobDataPointListParams) = apply { this.params = params } + fun params(params: AttachmentListParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun response(response: JobDataPointListPageResponse) = apply { this.response = response } + fun response(response: AttachmentListPageResponse) = apply { this.response = response } /** - * Returns an immutable instance of [JobDataPointListPageAsync]. + * Returns an immutable instance of [AttachmentListPageAsync]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -117,8 +118,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): JobDataPointListPageAsync = - JobDataPointListPageAsync( + fun build(): AttachmentListPageAsync = + AttachmentListPageAsync( checkRequired("service", service), checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), @@ -131,7 +132,7 @@ private constructor( return true } - return other is JobDataPointListPageAsync && + return other is AttachmentListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && @@ -141,5 +142,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) override fun toString() = - "JobDataPointListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" + "AttachmentListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPageResponse.kt new file mode 100644 index 0000000..6c39eba --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListPageResponse.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.beta.attachments + +import ai.llamaindex.llamacloud.core.ExcludeMissing +import ai.llamaindex.llamacloud.core.JsonField +import ai.llamaindex.llamacloud.core.JsonMissing +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.checkKnown +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +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 java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of file attachments. */ +class AttachmentListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val nextPageToken: JsonField, + private val totalSize: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of(), + @JsonProperty("next_page_token") + @ExcludeMissing + nextPageToken: JsonField = JsonMissing.of(), + @JsonProperty("total_size") @ExcludeMissing totalSize: JsonField = JsonMissing.of(), + ) : this(items, nextPageToken, totalSize, mutableMapOf()) + + /** + * The list of items. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * A token, which can be sent as page_token to retrieve the next page. If this field is omitted, + * there are no subsequent pages. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextPageToken(): Optional = nextPageToken.getOptional("next_page_token") + + /** + * The total number of items available. This is only populated when specifically requested. The + * value may be an estimate and can be used for display purposes only. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalSize(): Optional = totalSize.getOptional("total_size") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") + @ExcludeMissing + fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [nextPageToken]. + * + * Unlike [nextPageToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_page_token") + @ExcludeMissing + fun _nextPageToken(): JsonField = nextPageToken + + /** + * Returns the raw JSON value of [totalSize]. + * + * Unlike [totalSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_size") @ExcludeMissing fun _totalSize(): JsonField = totalSize + + @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 [AttachmentListPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentListPageResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var nextPageToken: JsonField = JsonMissing.of() + private var totalSize: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentListPageResponse: AttachmentListPageResponse) = apply { + items = attachmentListPageResponse.items.map { it.toMutableList() } + nextPageToken = attachmentListPageResponse.nextPageToken + totalSize = attachmentListPageResponse.totalSize + additionalProperties = attachmentListPageResponse.additionalProperties.toMutableMap() + } + + /** The list of items. */ + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [AttachmentListResponse] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: AttachmentListResponse) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** + * A token, which can be sent as page_token to retrieve the next page. If this field is + * omitted, there are no subsequent pages. + */ + fun nextPageToken(nextPageToken: String?) = + nextPageToken(JsonField.ofNullable(nextPageToken)) + + /** Alias for calling [Builder.nextPageToken] with `nextPageToken.orElse(null)`. */ + fun nextPageToken(nextPageToken: Optional) = + nextPageToken(nextPageToken.getOrNull()) + + /** + * Sets [Builder.nextPageToken] to an arbitrary JSON value. + * + * You should usually call [Builder.nextPageToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextPageToken(nextPageToken: JsonField) = apply { + this.nextPageToken = nextPageToken + } + + /** + * The total number of items available. This is only populated when specifically requested. + * The value may be an estimate and can be used for display purposes only. + */ + fun totalSize(totalSize: Long?) = totalSize(JsonField.ofNullable(totalSize)) + + /** + * Alias for [Builder.totalSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalSize(totalSize: Long) = totalSize(totalSize as Long?) + + /** Alias for calling [Builder.totalSize] with `totalSize.orElse(null)`. */ + fun totalSize(totalSize: Optional) = totalSize(totalSize.getOrNull()) + + /** + * Sets [Builder.totalSize] to an arbitrary JSON value. + * + * You should usually call [Builder.totalSize] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun totalSize(totalSize: JsonField) = apply { this.totalSize = totalSize } + + 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 [AttachmentListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentListPageResponse = + AttachmentListPageResponse( + checkRequired("items", items).map { it.toImmutable() }, + nextPageToken, + totalSize, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AttachmentListPageResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + nextPageToken() + totalSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextPageToken.asKnown().isPresent) 1 else 0) + + (if (totalSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentListPageResponse && + items == other.items && + nextPageToken == other.nextPageToken && + totalSize == other.totalSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(items, nextPageToken, totalSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListParams.kt new file mode 100644 index 0000000..053cad3 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.beta.attachments + +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List the attachments associated with a file (e.g. per-page screenshots). */ +class AttachmentListParams +private constructor( + private val sourceId: String, + private val organizationId: String?, + private val pageSize: Long?, + private val pageToken: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** File UUID or directory file ID (dfl-...). */ + fun sourceId(): String = sourceId + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun pageToken(): Optional = Optional.ofNullable(pageToken) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AttachmentListParams]. + * + * The following fields are required: + * ```java + * .sourceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentListParams]. */ + class Builder internal constructor() { + + private var sourceId: String? = null + private var organizationId: String? = null + private var pageSize: Long? = null + private var pageToken: String? = null + private var projectId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(attachmentListParams: AttachmentListParams) = apply { + sourceId = attachmentListParams.sourceId + organizationId = attachmentListParams.organizationId + pageSize = attachmentListParams.pageSize + pageToken = attachmentListParams.pageToken + projectId = attachmentListParams.projectId + additionalHeaders = attachmentListParams.additionalHeaders.toBuilder() + additionalQueryParams = attachmentListParams.additionalQueryParams.toBuilder() + } + + /** File UUID or directory file ID (dfl-...). */ + fun sourceId(sourceId: String) = apply { this.sourceId = sourceId } + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } + + /** Alias for calling [Builder.pageToken] with `pageToken.orElse(null)`. */ + fun pageToken(pageToken: Optional) = pageToken(pageToken.getOrNull()) + + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AttachmentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentListParams = + AttachmentListParams( + checkRequired("sourceId", sourceId), + organizationId, + pageSize, + pageToken, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + put("source_id", sourceId) + organizationId?.let { put("organization_id", it) } + pageSize?.let { put("page_size", it.toString()) } + pageToken?.let { put("page_token", it) } + projectId?.let { put("project_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentListParams && + sourceId == other.sourceId && + organizationId == other.organizationId && + pageSize == other.pageSize && + pageToken == other.pageToken && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + sourceId, + organizationId, + pageSize, + pageToken, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "AttachmentListParams{sourceId=$sourceId, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListResponse.kt new file mode 100644 index 0000000..8bc5679 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/attachments/AttachmentListResponse.kt @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.beta.attachments + +import ai.llamaindex.llamacloud.core.ExcludeMissing +import ai.llamaindex.llamacloud.core.JsonField +import ai.llamaindex.llamacloud.core.JsonMissing +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +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 java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Metadata for a single file attachment. */ +class AttachmentListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val name: JsonField, + private val size: JsonField, + private val lastModified: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("last_modified") + @ExcludeMissing + lastModified: JsonField = JsonMissing.of(), + ) : this(name, size, lastModified, mutableMapOf()) + + /** + * Name of the attachment + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Size of the attachment in bytes + * + * @throws LlamaCloudInvalidDataException 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 size(): Long = size.getRequired("size") + + /** + * When the attachment was last modified + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastModified(): Optional = lastModified.getOptional("last_modified") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [lastModified]. + * + * Unlike [lastModified], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_modified") + @ExcludeMissing + fun _lastModified(): JsonField = lastModified + + @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 [AttachmentListResponse]. + * + * The following fields are required: + * ```java + * .name() + * .size() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentListResponse]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var size: JsonField? = null + private var lastModified: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentListResponse: AttachmentListResponse) = apply { + name = attachmentListResponse.name + size = attachmentListResponse.size + lastModified = attachmentListResponse.lastModified + additionalProperties = attachmentListResponse.additionalProperties.toMutableMap() + } + + /** Name of the attachment */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Size of the attachment in bytes */ + fun size(size: Long) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** When the attachment was last modified */ + fun lastModified(lastModified: OffsetDateTime?) = + lastModified(JsonField.ofNullable(lastModified)) + + /** Alias for calling [Builder.lastModified] with `lastModified.orElse(null)`. */ + fun lastModified(lastModified: Optional) = + lastModified(lastModified.getOrNull()) + + /** + * Sets [Builder.lastModified] to an arbitrary JSON value. + * + * You should usually call [Builder.lastModified] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastModified(lastModified: JsonField) = apply { + this.lastModified = lastModified + } + + 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 [AttachmentListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .size() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentListResponse = + AttachmentListResponse( + checkRequired("name", name), + checkRequired("size", size), + lastModified, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AttachmentListResponse = apply { + if (validated) { + return@apply + } + + name() + size() + lastModified() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (if (lastModified.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentListResponse && + name == other.name && + size == other.size && + lastModified == other.lastModified && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, size, lastModified, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentListResponse{name=$name, size=$size, lastModified=$lastModified, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateParams.kt index e327bd6..283d2e0 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateParams.kt @@ -2,6 +2,7 @@ package ai.llamaindex.llamacloud.models.beta.chat +import ai.llamaindex.llamacloud.core.Enum import ai.llamaindex.llamacloud.core.ExcludeMissing import ai.llamaindex.llamacloud.core.JsonField import ai.llamaindex.llamacloud.core.JsonMissing @@ -44,6 +45,15 @@ private constructor( */ fun indexIds(): Optional> = body.indexIds() + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). Null follows the deployment default. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sharedAccess(): Optional = body.sharedAccess() + /** * Returns the raw JSON value of [indexIds]. * @@ -51,6 +61,13 @@ private constructor( */ fun _indexIds(): JsonField> = body._indexIds() + /** + * Returns the raw JSON value of [sharedAccess]. + * + * Unlike [sharedAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sharedAccess(): JsonField = body._sharedAccess() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -104,6 +121,7 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [indexIds] + * - [sharedAccess] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -133,6 +151,27 @@ private constructor( */ fun addIndexId(indexId: String) = apply { body.addIndexId(indexId) } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask + * new questions). Null follows the deployment default. + */ + fun sharedAccess(sharedAccess: SharedAccess?) = apply { body.sharedAccess(sharedAccess) } + + /** Alias for calling [Builder.sharedAccess] with `sharedAccess.orElse(null)`. */ + fun sharedAccess(sharedAccess: Optional) = + sharedAccess(sharedAccess.getOrNull()) + + /** + * Sets [Builder.sharedAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedAccess] with a well-typed [SharedAccess] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedAccess(sharedAccess: JsonField) = apply { + body.sharedAccess(sharedAccess) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -283,6 +322,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val indexIds: JsonField>, + private val sharedAccess: JsonField, private val additionalProperties: MutableMap, ) { @@ -290,8 +330,11 @@ private constructor( private constructor( @JsonProperty("index_ids") @ExcludeMissing - indexIds: JsonField> = JsonMissing.of() - ) : this(indexIds, mutableMapOf()) + indexIds: JsonField> = JsonMissing.of(), + @JsonProperty("shared_access") + @ExcludeMissing + sharedAccess: JsonField = JsonMissing.of(), + ) : this(indexIds, sharedAccess, mutableMapOf()) /** * Indexes this session will retrieve from. Once set and the first message has been sent, @@ -303,6 +346,15 @@ private constructor( */ fun indexIds(): Optional> = indexIds.getOptional("index_ids") + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask + * new questions). Null follows the deployment default. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun sharedAccess(): Optional = sharedAccess.getOptional("shared_access") + /** * Returns the raw JSON value of [indexIds]. * @@ -312,6 +364,16 @@ private constructor( @ExcludeMissing fun _indexIds(): JsonField> = indexIds + /** + * Returns the raw JSON value of [sharedAccess]. + * + * Unlike [sharedAccess], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shared_access") + @ExcludeMissing + fun _sharedAccess(): JsonField = sharedAccess + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -334,11 +396,13 @@ private constructor( class Builder internal constructor() { private var indexIds: JsonField>? = null + private var sharedAccess: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { indexIds = body.indexIds.map { it.toMutableList() } + sharedAccess = body.sharedAccess additionalProperties = body.additionalProperties.toMutableMap() } @@ -375,6 +439,28 @@ private constructor( } } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may + * ask new questions). Null follows the deployment default. + */ + fun sharedAccess(sharedAccess: SharedAccess?) = + sharedAccess(JsonField.ofNullable(sharedAccess)) + + /** Alias for calling [Builder.sharedAccess] with `sharedAccess.orElse(null)`. */ + fun sharedAccess(sharedAccess: Optional) = + sharedAccess(sharedAccess.getOrNull()) + + /** + * Sets [Builder.sharedAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedAccess] with a well-typed [SharedAccess] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedAccess(sharedAccess: JsonField) = apply { + this.sharedAccess = sharedAccess + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -402,6 +488,7 @@ private constructor( fun build(): Body = Body( (indexIds ?: JsonMissing.of()).map { it.toImmutable() }, + sharedAccess, additionalProperties.toMutableMap(), ) } @@ -423,6 +510,7 @@ private constructor( } indexIds() + sharedAccess().ifPresent { it.validate() } validated = true } @@ -440,7 +528,10 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (indexIds.asKnown().getOrNull()?.size ?: 0) + @JvmSynthetic + internal fun validity(): Int = + (indexIds.asKnown().getOrNull()?.size ?: 0) + + (sharedAccess.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -449,15 +540,161 @@ private constructor( return other is Body && indexIds == other.indexIds && + sharedAccess == other.sharedAccess && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(indexIds, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(indexIds, sharedAccess, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{indexIds=$indexIds, additionalProperties=$additionalProperties}" + "Body{indexIds=$indexIds, sharedAccess=$sharedAccess, additionalProperties=$additionalProperties}" + } + + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). Null follows the deployment default. + */ + class SharedAccess @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 QUERY = of("query") + + @JvmField val READ_ONLY = of("read_only") + + @JvmStatic fun of(value: String) = SharedAccess(JsonField.of(value)) + } + + /** An enum containing [SharedAccess]'s known values. */ + enum class Known { + QUERY, + READ_ONLY, + } + + /** + * An enum containing [SharedAccess]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SharedAccess] 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 { + QUERY, + READ_ONLY, + /** + * An enum member indicating that [SharedAccess] 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) { + QUERY -> Value.QUERY + READ_ONLY -> Value.READ_ONLY + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUERY -> Known.QUERY + READ_ONLY -> Known.READ_ONLY + else -> throw LlamaCloudInvalidDataException("Unknown SharedAccess: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SharedAccess = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 SharedAccess && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateResponse.kt index 0348e7c..35c0c21 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatCreateResponse.kt @@ -2,6 +2,7 @@ package ai.llamaindex.llamacloud.models.beta.chat +import ai.llamaindex.llamacloud.core.Enum import ai.llamaindex.llamacloud.core.ExcludeMissing import ai.llamaindex.llamacloud.core.JsonField import ai.llamaindex.llamacloud.core.JsonMissing @@ -25,6 +26,7 @@ class ChatCreateResponse private constructor( private val lastUpdatedAt: JsonField, private val sessionId: JsonField, + private val sharedAccess: JsonField, private val generatedTitle: JsonField, private val indexIds: JsonField>, private val jobMetadata: JsonField, @@ -37,6 +39,9 @@ private constructor( @ExcludeMissing lastUpdatedAt: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("shared_access") + @ExcludeMissing + sharedAccess: JsonField = JsonMissing.of(), @JsonProperty("generated_title") @ExcludeMissing generatedTitle: JsonField = JsonMissing.of(), @@ -46,7 +51,15 @@ private constructor( @JsonProperty("job_metadata") @ExcludeMissing jobMetadata: JsonField = JsonMissing.of(), - ) : this(lastUpdatedAt, sessionId, generatedTitle, indexIds, jobMetadata, mutableMapOf()) + ) : this( + lastUpdatedAt, + sessionId, + sharedAccess, + generatedTitle, + indexIds, + jobMetadata, + mutableMapOf(), + ) /** * ISO-format timestamp showing when the session was last updated. @@ -64,6 +77,15 @@ private constructor( */ fun sessionId(): String = sessionId.getRequired("session_id") + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + * + * @throws LlamaCloudInvalidDataException 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 sharedAccess(): SharedAccess = sharedAccess.getRequired("shared_access") + /** * Auto-generated title derived from the first user message. * @@ -104,6 +126,15 @@ private constructor( */ @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + /** + * Returns the raw JSON value of [sharedAccess]. + * + * Unlike [sharedAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shared_access") + @ExcludeMissing + fun _sharedAccess(): JsonField = sharedAccess + /** * Returns the raw JSON value of [generatedTitle]. * @@ -150,6 +181,7 @@ private constructor( * ```java * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` */ @JvmStatic fun builder() = Builder() @@ -160,6 +192,7 @@ private constructor( private var lastUpdatedAt: JsonField? = null private var sessionId: JsonField? = null + private var sharedAccess: JsonField? = null private var generatedTitle: JsonField = JsonMissing.of() private var indexIds: JsonField>? = null private var jobMetadata: JsonField = JsonMissing.of() @@ -169,6 +202,7 @@ private constructor( internal fun from(chatCreateResponse: ChatCreateResponse) = apply { lastUpdatedAt = chatCreateResponse.lastUpdatedAt sessionId = chatCreateResponse.sessionId + sharedAccess = chatCreateResponse.sharedAccess generatedTitle = chatCreateResponse.generatedTitle indexIds = chatCreateResponse.indexIds.map { it.toMutableList() } jobMetadata = chatCreateResponse.jobMetadata @@ -201,6 +235,23 @@ private constructor( */ fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask + * new questions). + */ + fun sharedAccess(sharedAccess: SharedAccess) = sharedAccess(JsonField.of(sharedAccess)) + + /** + * Sets [Builder.sharedAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedAccess] with a well-typed [SharedAccess] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedAccess(sharedAccess: JsonField) = apply { + this.sharedAccess = sharedAccess + } + /** Auto-generated title derived from the first user message. */ fun generatedTitle(generatedTitle: String?) = generatedTitle(JsonField.ofNullable(generatedTitle)) @@ -297,6 +348,7 @@ private constructor( * ```java * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` * * @throws IllegalStateException if any required field is unset. @@ -305,6 +357,7 @@ private constructor( ChatCreateResponse( checkRequired("lastUpdatedAt", lastUpdatedAt), checkRequired("sessionId", sessionId), + checkRequired("sharedAccess", sharedAccess), generatedTitle, (indexIds ?: JsonMissing.of()).map { it.toImmutable() }, jobMetadata, @@ -329,6 +382,7 @@ private constructor( lastUpdatedAt() sessionId() + sharedAccess().validate() generatedTitle() indexIds() jobMetadata().ifPresent { it.validate() } @@ -352,10 +406,154 @@ private constructor( internal fun validity(): Int = (if (lastUpdatedAt.asKnown().isPresent) 1 else 0) + (if (sessionId.asKnown().isPresent) 1 else 0) + + (sharedAccess.asKnown().getOrNull()?.validity() ?: 0) + (if (generatedTitle.asKnown().isPresent) 1 else 0) + (indexIds.asKnown().getOrNull()?.size ?: 0) + (jobMetadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + */ + class SharedAccess @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 QUERY = of("query") + + @JvmField val READ_ONLY = of("read_only") + + @JvmStatic fun of(value: String) = SharedAccess(JsonField.of(value)) + } + + /** An enum containing [SharedAccess]'s known values. */ + enum class Known { + QUERY, + READ_ONLY, + } + + /** + * An enum containing [SharedAccess]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SharedAccess] 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 { + QUERY, + READ_ONLY, + /** + * An enum member indicating that [SharedAccess] 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) { + QUERY -> Value.QUERY + READ_ONLY -> Value.READ_ONLY + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUERY -> Known.QUERY + READ_ONLY -> Known.READ_ONLY + else -> throw LlamaCloudInvalidDataException("Unknown SharedAccess: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SharedAccess = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 SharedAccess && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Token usage and status from the most recent run. Null if the session has not been run yet. */ @@ -811,6 +1009,7 @@ private constructor( return other is ChatCreateResponse && lastUpdatedAt == other.lastUpdatedAt && sessionId == other.sessionId && + sharedAccess == other.sharedAccess && generatedTitle == other.generatedTitle && indexIds == other.indexIds && jobMetadata == other.jobMetadata && @@ -821,6 +1020,7 @@ private constructor( Objects.hash( lastUpdatedAt, sessionId, + sharedAccess, generatedTitle, indexIds, jobMetadata, @@ -831,5 +1031,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ChatCreateResponse{lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" + "ChatCreateResponse{lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, sharedAccess=$sharedAccess, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatGetSummaryResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatGetSummaryResponse.kt index 2601b3f..9cad142 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatGetSummaryResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatGetSummaryResponse.kt @@ -2,6 +2,7 @@ package ai.llamaindex.llamacloud.models.beta.chat +import ai.llamaindex.llamacloud.core.Enum import ai.llamaindex.llamacloud.core.ExcludeMissing import ai.llamaindex.llamacloud.core.JsonField import ai.llamaindex.llamacloud.core.JsonMissing @@ -25,6 +26,7 @@ class ChatGetSummaryResponse private constructor( private val lastUpdatedAt: JsonField, private val sessionId: JsonField, + private val sharedAccess: JsonField, private val generatedTitle: JsonField, private val indexIds: JsonField>, private val jobMetadata: JsonField, @@ -37,6 +39,9 @@ private constructor( @ExcludeMissing lastUpdatedAt: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("shared_access") + @ExcludeMissing + sharedAccess: JsonField = JsonMissing.of(), @JsonProperty("generated_title") @ExcludeMissing generatedTitle: JsonField = JsonMissing.of(), @@ -46,7 +51,15 @@ private constructor( @JsonProperty("job_metadata") @ExcludeMissing jobMetadata: JsonField = JsonMissing.of(), - ) : this(lastUpdatedAt, sessionId, generatedTitle, indexIds, jobMetadata, mutableMapOf()) + ) : this( + lastUpdatedAt, + sessionId, + sharedAccess, + generatedTitle, + indexIds, + jobMetadata, + mutableMapOf(), + ) /** * ISO-format timestamp showing when the session was last updated. @@ -64,6 +77,15 @@ private constructor( */ fun sessionId(): String = sessionId.getRequired("session_id") + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + * + * @throws LlamaCloudInvalidDataException 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 sharedAccess(): SharedAccess = sharedAccess.getRequired("shared_access") + /** * Auto-generated title derived from the first user message. * @@ -104,6 +126,15 @@ private constructor( */ @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + /** + * Returns the raw JSON value of [sharedAccess]. + * + * Unlike [sharedAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shared_access") + @ExcludeMissing + fun _sharedAccess(): JsonField = sharedAccess + /** * Returns the raw JSON value of [generatedTitle]. * @@ -150,6 +181,7 @@ private constructor( * ```java * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` */ @JvmStatic fun builder() = Builder() @@ -160,6 +192,7 @@ private constructor( private var lastUpdatedAt: JsonField? = null private var sessionId: JsonField? = null + private var sharedAccess: JsonField? = null private var generatedTitle: JsonField = JsonMissing.of() private var indexIds: JsonField>? = null private var jobMetadata: JsonField = JsonMissing.of() @@ -169,6 +202,7 @@ private constructor( internal fun from(chatGetSummaryResponse: ChatGetSummaryResponse) = apply { lastUpdatedAt = chatGetSummaryResponse.lastUpdatedAt sessionId = chatGetSummaryResponse.sessionId + sharedAccess = chatGetSummaryResponse.sharedAccess generatedTitle = chatGetSummaryResponse.generatedTitle indexIds = chatGetSummaryResponse.indexIds.map { it.toMutableList() } jobMetadata = chatGetSummaryResponse.jobMetadata @@ -201,6 +235,23 @@ private constructor( */ fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask + * new questions). + */ + fun sharedAccess(sharedAccess: SharedAccess) = sharedAccess(JsonField.of(sharedAccess)) + + /** + * Sets [Builder.sharedAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedAccess] with a well-typed [SharedAccess] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedAccess(sharedAccess: JsonField) = apply { + this.sharedAccess = sharedAccess + } + /** Auto-generated title derived from the first user message. */ fun generatedTitle(generatedTitle: String?) = generatedTitle(JsonField.ofNullable(generatedTitle)) @@ -297,6 +348,7 @@ private constructor( * ```java * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` * * @throws IllegalStateException if any required field is unset. @@ -305,6 +357,7 @@ private constructor( ChatGetSummaryResponse( checkRequired("lastUpdatedAt", lastUpdatedAt), checkRequired("sessionId", sessionId), + checkRequired("sharedAccess", sharedAccess), generatedTitle, (indexIds ?: JsonMissing.of()).map { it.toImmutable() }, jobMetadata, @@ -329,6 +382,7 @@ private constructor( lastUpdatedAt() sessionId() + sharedAccess().validate() generatedTitle() indexIds() jobMetadata().ifPresent { it.validate() } @@ -352,10 +406,154 @@ private constructor( internal fun validity(): Int = (if (lastUpdatedAt.asKnown().isPresent) 1 else 0) + (if (sessionId.asKnown().isPresent) 1 else 0) + + (sharedAccess.asKnown().getOrNull()?.validity() ?: 0) + (if (generatedTitle.asKnown().isPresent) 1 else 0) + (indexIds.asKnown().getOrNull()?.size ?: 0) + (jobMetadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + */ + class SharedAccess @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 QUERY = of("query") + + @JvmField val READ_ONLY = of("read_only") + + @JvmStatic fun of(value: String) = SharedAccess(JsonField.of(value)) + } + + /** An enum containing [SharedAccess]'s known values. */ + enum class Known { + QUERY, + READ_ONLY, + } + + /** + * An enum containing [SharedAccess]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SharedAccess] 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 { + QUERY, + READ_ONLY, + /** + * An enum member indicating that [SharedAccess] 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) { + QUERY -> Value.QUERY + READ_ONLY -> Value.READ_ONLY + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUERY -> Known.QUERY + READ_ONLY -> Known.READ_ONLY + else -> throw LlamaCloudInvalidDataException("Unknown SharedAccess: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SharedAccess = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 SharedAccess && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Token usage and status from the most recent run. Null if the session has not been run yet. */ @@ -811,6 +1009,7 @@ private constructor( return other is ChatGetSummaryResponse && lastUpdatedAt == other.lastUpdatedAt && sessionId == other.sessionId && + sharedAccess == other.sharedAccess && generatedTitle == other.generatedTitle && indexIds == other.indexIds && jobMetadata == other.jobMetadata && @@ -821,6 +1020,7 @@ private constructor( Objects.hash( lastUpdatedAt, sessionId, + sharedAccess, generatedTitle, indexIds, jobMetadata, @@ -831,5 +1031,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ChatGetSummaryResponse{lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" + "ChatGetSummaryResponse{lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, sharedAccess=$sharedAccess, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatListResponse.kt index 160e1f7..dd71d0f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatListResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatListResponse.kt @@ -2,6 +2,7 @@ package ai.llamaindex.llamacloud.models.beta.chat +import ai.llamaindex.llamacloud.core.Enum import ai.llamaindex.llamacloud.core.ExcludeMissing import ai.llamaindex.llamacloud.core.JsonField import ai.llamaindex.llamacloud.core.JsonMissing @@ -25,6 +26,7 @@ class ChatListResponse private constructor( private val lastUpdatedAt: JsonField, private val sessionId: JsonField, + private val sharedAccess: JsonField, private val generatedTitle: JsonField, private val indexIds: JsonField>, private val jobMetadata: JsonField, @@ -37,6 +39,9 @@ private constructor( @ExcludeMissing lastUpdatedAt: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("shared_access") + @ExcludeMissing + sharedAccess: JsonField = JsonMissing.of(), @JsonProperty("generated_title") @ExcludeMissing generatedTitle: JsonField = JsonMissing.of(), @@ -46,7 +51,15 @@ private constructor( @JsonProperty("job_metadata") @ExcludeMissing jobMetadata: JsonField = JsonMissing.of(), - ) : this(lastUpdatedAt, sessionId, generatedTitle, indexIds, jobMetadata, mutableMapOf()) + ) : this( + lastUpdatedAt, + sessionId, + sharedAccess, + generatedTitle, + indexIds, + jobMetadata, + mutableMapOf(), + ) /** * ISO-format timestamp showing when the session was last updated. @@ -64,6 +77,15 @@ private constructor( */ fun sessionId(): String = sessionId.getRequired("session_id") + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + * + * @throws LlamaCloudInvalidDataException 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 sharedAccess(): SharedAccess = sharedAccess.getRequired("shared_access") + /** * Auto-generated title derived from the first user message. * @@ -104,6 +126,15 @@ private constructor( */ @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + /** + * Returns the raw JSON value of [sharedAccess]. + * + * Unlike [sharedAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shared_access") + @ExcludeMissing + fun _sharedAccess(): JsonField = sharedAccess + /** * Returns the raw JSON value of [generatedTitle]. * @@ -150,6 +181,7 @@ private constructor( * ```java * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` */ @JvmStatic fun builder() = Builder() @@ -160,6 +192,7 @@ private constructor( private var lastUpdatedAt: JsonField? = null private var sessionId: JsonField? = null + private var sharedAccess: JsonField? = null private var generatedTitle: JsonField = JsonMissing.of() private var indexIds: JsonField>? = null private var jobMetadata: JsonField = JsonMissing.of() @@ -169,6 +202,7 @@ private constructor( internal fun from(chatListResponse: ChatListResponse) = apply { lastUpdatedAt = chatListResponse.lastUpdatedAt sessionId = chatListResponse.sessionId + sharedAccess = chatListResponse.sharedAccess generatedTitle = chatListResponse.generatedTitle indexIds = chatListResponse.indexIds.map { it.toMutableList() } jobMetadata = chatListResponse.jobMetadata @@ -201,6 +235,23 @@ private constructor( */ fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask + * new questions). + */ + fun sharedAccess(sharedAccess: SharedAccess) = sharedAccess(JsonField.of(sharedAccess)) + + /** + * Sets [Builder.sharedAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedAccess] with a well-typed [SharedAccess] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedAccess(sharedAccess: JsonField) = apply { + this.sharedAccess = sharedAccess + } + /** Auto-generated title derived from the first user message. */ fun generatedTitle(generatedTitle: String?) = generatedTitle(JsonField.ofNullable(generatedTitle)) @@ -297,6 +348,7 @@ private constructor( * ```java * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` * * @throws IllegalStateException if any required field is unset. @@ -305,6 +357,7 @@ private constructor( ChatListResponse( checkRequired("lastUpdatedAt", lastUpdatedAt), checkRequired("sessionId", sessionId), + checkRequired("sharedAccess", sharedAccess), generatedTitle, (indexIds ?: JsonMissing.of()).map { it.toImmutable() }, jobMetadata, @@ -329,6 +382,7 @@ private constructor( lastUpdatedAt() sessionId() + sharedAccess().validate() generatedTitle() indexIds() jobMetadata().ifPresent { it.validate() } @@ -352,10 +406,154 @@ private constructor( internal fun validity(): Int = (if (lastUpdatedAt.asKnown().isPresent) 1 else 0) + (if (sessionId.asKnown().isPresent) 1 else 0) + + (sharedAccess.asKnown().getOrNull()?.validity() ?: 0) + (if (generatedTitle.asKnown().isPresent) 1 else 0) + (indexIds.asKnown().getOrNull()?.size ?: 0) + (jobMetadata.asKnown().getOrNull()?.validity() ?: 0) + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + */ + class SharedAccess @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 QUERY = of("query") + + @JvmField val READ_ONLY = of("read_only") + + @JvmStatic fun of(value: String) = SharedAccess(JsonField.of(value)) + } + + /** An enum containing [SharedAccess]'s known values. */ + enum class Known { + QUERY, + READ_ONLY, + } + + /** + * An enum containing [SharedAccess]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SharedAccess] 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 { + QUERY, + READ_ONLY, + /** + * An enum member indicating that [SharedAccess] 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) { + QUERY -> Value.QUERY + READ_ONLY -> Value.READ_ONLY + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUERY -> Known.QUERY + READ_ONLY -> Known.READ_ONLY + else -> throw LlamaCloudInvalidDataException("Unknown SharedAccess: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SharedAccess = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 SharedAccess && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Token usage and status from the most recent run. Null if the session has not been run yet. */ @@ -811,6 +1009,7 @@ private constructor( return other is ChatListResponse && lastUpdatedAt == other.lastUpdatedAt && sessionId == other.sessionId && + sharedAccess == other.sharedAccess && generatedTitle == other.generatedTitle && indexIds == other.indexIds && jobMetadata == other.jobMetadata && @@ -821,6 +1020,7 @@ private constructor( Objects.hash( lastUpdatedAt, sessionId, + sharedAccess, generatedTitle, indexIds, jobMetadata, @@ -831,5 +1031,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ChatListResponse{lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" + "ChatListResponse{lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, sharedAccess=$sharedAccess, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatRetrieveResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatRetrieveResponse.kt index b7dc325..d720488 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatRetrieveResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatRetrieveResponse.kt @@ -37,6 +37,7 @@ private constructor( private val events: JsonField>, private val lastUpdatedAt: JsonField, private val sessionId: JsonField, + private val sharedAccess: JsonField, private val generatedTitle: JsonField, private val indexIds: JsonField>, private val jobMetadata: JsonField, @@ -50,6 +51,9 @@ private constructor( @ExcludeMissing lastUpdatedAt: JsonField = JsonMissing.of(), @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("shared_access") + @ExcludeMissing + sharedAccess: JsonField = JsonMissing.of(), @JsonProperty("generated_title") @ExcludeMissing generatedTitle: JsonField = JsonMissing.of(), @@ -63,6 +67,7 @@ private constructor( events, lastUpdatedAt, sessionId, + sharedAccess, generatedTitle, indexIds, jobMetadata, @@ -93,6 +98,15 @@ private constructor( */ fun sessionId(): String = sessionId.getRequired("session_id") + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + * + * @throws LlamaCloudInvalidDataException 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 sharedAccess(): SharedAccess = sharedAccess.getRequired("shared_access") + /** * Auto-generated title derived from the first user message. * @@ -140,6 +154,15 @@ private constructor( */ @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + /** + * Returns the raw JSON value of [sharedAccess]. + * + * Unlike [sharedAccess], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shared_access") + @ExcludeMissing + fun _sharedAccess(): JsonField = sharedAccess + /** * Returns the raw JSON value of [generatedTitle]. * @@ -187,6 +210,7 @@ private constructor( * .events() * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` */ @JvmStatic fun builder() = Builder() @@ -198,6 +222,7 @@ private constructor( private var events: JsonField>? = null private var lastUpdatedAt: JsonField? = null private var sessionId: JsonField? = null + private var sharedAccess: JsonField? = null private var generatedTitle: JsonField = JsonMissing.of() private var indexIds: JsonField>? = null private var jobMetadata: JsonField = JsonMissing.of() @@ -208,6 +233,7 @@ private constructor( events = chatRetrieveResponse.events.map { it.toMutableList() } lastUpdatedAt = chatRetrieveResponse.lastUpdatedAt sessionId = chatRetrieveResponse.sessionId + sharedAccess = chatRetrieveResponse.sharedAccess generatedTitle = chatRetrieveResponse.generatedTitle indexIds = chatRetrieveResponse.indexIds.map { it.toMutableList() } jobMetadata = chatRetrieveResponse.jobMetadata @@ -376,6 +402,23 @@ private constructor( */ fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask + * new questions). + */ + fun sharedAccess(sharedAccess: SharedAccess) = sharedAccess(JsonField.of(sharedAccess)) + + /** + * Sets [Builder.sharedAccess] to an arbitrary JSON value. + * + * You should usually call [Builder.sharedAccess] with a well-typed [SharedAccess] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sharedAccess(sharedAccess: JsonField) = apply { + this.sharedAccess = sharedAccess + } + /** Auto-generated title derived from the first user message. */ fun generatedTitle(generatedTitle: String?) = generatedTitle(JsonField.ofNullable(generatedTitle)) @@ -473,6 +516,7 @@ private constructor( * .events() * .lastUpdatedAt() * .sessionId() + * .sharedAccess() * ``` * * @throws IllegalStateException if any required field is unset. @@ -482,6 +526,7 @@ private constructor( checkRequired("events", events).map { it.toImmutable() }, checkRequired("lastUpdatedAt", lastUpdatedAt), checkRequired("sessionId", sessionId), + checkRequired("sharedAccess", sharedAccess), generatedTitle, (indexIds ?: JsonMissing.of()).map { it.toImmutable() }, jobMetadata, @@ -507,6 +552,7 @@ private constructor( events().forEach { it.validate() } lastUpdatedAt() sessionId() + sharedAccess().validate() generatedTitle() indexIds() jobMetadata().ifPresent { it.validate() } @@ -531,6 +577,7 @@ private constructor( (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (lastUpdatedAt.asKnown().isPresent) 1 else 0) + (if (sessionId.asKnown().isPresent) 1 else 0) + + (sharedAccess.asKnown().getOrNull()?.validity() ?: 0) + (if (generatedTitle.asKnown().isPresent) 1 else 0) + (indexIds.asKnown().getOrNull()?.size ?: 0) + (jobMetadata.asKnown().getOrNull()?.validity() ?: 0) @@ -912,6 +959,7 @@ private constructor( private val error: JsonField, private val isError: JsonField, private val usage: JsonField, + private val skippedIndexIds: JsonField>, private val type: JsonField, private val additionalProperties: MutableMap, ) { @@ -923,8 +971,11 @@ private constructor( @ExcludeMissing isError: JsonField = JsonMissing.of(), @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), + @JsonProperty("skipped_index_ids") + @ExcludeMissing + skippedIndexIds: JsonField> = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(error, isError, usage, type, mutableMapOf()) + ) : this(error, isError, usage, skippedIndexIds, type, mutableMapOf()) /** * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. @@ -946,6 +997,15 @@ private constructor( */ fun usage(): Usage = usage.getRequired("usage") + /** + * Requested indexes this turn could not query. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun skippedIndexIds(): Optional> = + skippedIndexIds.getOptional("skipped_index_ids") + /** * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -973,6 +1033,16 @@ private constructor( */ @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + /** + * Returns the raw JSON value of [skippedIndexIds]. + * + * Unlike [skippedIndexIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("skipped_index_ids") + @ExcludeMissing + fun _skippedIndexIds(): JsonField> = skippedIndexIds + /** * Returns the raw JSON value of [type]. * @@ -1013,6 +1083,7 @@ private constructor( private var error: JsonField? = null private var isError: JsonField? = null private var usage: JsonField? = null + private var skippedIndexIds: JsonField>? = null private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1021,6 +1092,7 @@ private constructor( error = stop.error isError = stop.isError usage = stop.usage + skippedIndexIds = stop.skippedIndexIds.map { it.toMutableList() } type = stop.type additionalProperties = stop.additionalProperties.toMutableMap() } @@ -1061,6 +1133,33 @@ private constructor( */ fun usage(usage: JsonField) = apply { this.usage = usage } + /** Requested indexes this turn could not query. */ + fun skippedIndexIds(skippedIndexIds: List) = + skippedIndexIds(JsonField.of(skippedIndexIds)) + + /** + * Sets [Builder.skippedIndexIds] to an arbitrary JSON value. + * + * You should usually call [Builder.skippedIndexIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun skippedIndexIds(skippedIndexIds: JsonField>) = apply { + this.skippedIndexIds = skippedIndexIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [skippedIndexIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSkippedIndexId(skippedIndexId: String) = apply { + skippedIndexIds = + (skippedIndexIds ?: JsonField.of(mutableListOf())).also { + checkKnown("skippedIndexIds", it).add(skippedIndexId) + } + } + fun type(type: Type) = type(JsonField.of(type)) /** @@ -1113,6 +1212,7 @@ private constructor( checkRequired("error", error), checkRequired("isError", isError), checkRequired("usage", usage), + (skippedIndexIds ?: JsonMissing.of()).map { it.toImmutable() }, type, additionalProperties.toMutableMap(), ) @@ -1138,6 +1238,7 @@ private constructor( error() isError() usage().validate() + skippedIndexIds() type().ifPresent { it.validate() } validated = true } @@ -1161,6 +1262,7 @@ private constructor( (if (error.asKnown().isPresent) 1 else 0) + (if (isError.asKnown().isPresent) 1 else 0) + (usage.asKnown().getOrNull()?.validity() ?: 0) + + (skippedIndexIds.asKnown().getOrNull()?.size ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) class Usage @@ -1623,18 +1725,19 @@ private constructor( error == other.error && isError == other.isError && usage == other.usage && + skippedIndexIds == other.skippedIndexIds && type == other.type && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(error, isError, usage, type, additionalProperties) + Objects.hash(error, isError, usage, skippedIndexIds, type, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Stop{error=$error, isError=$isError, usage=$usage, type=$type, additionalProperties=$additionalProperties}" + "Stop{error=$error, isError=$isError, usage=$usage, skippedIndexIds=$skippedIndexIds, type=$type, additionalProperties=$additionalProperties}" } class TextDelta @@ -4540,6 +4643,149 @@ private constructor( } } + /** + * What this chat's share link grants: read_only (transcript only) or query (viewers may ask new + * questions). + */ + class SharedAccess @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 QUERY = of("query") + + @JvmField val READ_ONLY = of("read_only") + + @JvmStatic fun of(value: String) = SharedAccess(JsonField.of(value)) + } + + /** An enum containing [SharedAccess]'s known values. */ + enum class Known { + QUERY, + READ_ONLY, + } + + /** + * An enum containing [SharedAccess]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SharedAccess] 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 { + QUERY, + READ_ONLY, + /** + * An enum member indicating that [SharedAccess] 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) { + QUERY -> Value.QUERY + READ_ONLY -> Value.READ_ONLY + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUERY -> Known.QUERY + READ_ONLY -> Known.READ_ONLY + else -> throw LlamaCloudInvalidDataException("Unknown SharedAccess: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SharedAccess = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 SharedAccess && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Token usage and status from the most recent run. Null if the session has not been run yet. */ @@ -4996,6 +5242,7 @@ private constructor( events == other.events && lastUpdatedAt == other.lastUpdatedAt && sessionId == other.sessionId && + sharedAccess == other.sharedAccess && generatedTitle == other.generatedTitle && indexIds == other.indexIds && jobMetadata == other.jobMetadata && @@ -5007,6 +5254,7 @@ private constructor( events, lastUpdatedAt, sessionId, + sharedAccess, generatedTitle, indexIds, jobMetadata, @@ -5017,5 +5265,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ChatRetrieveResponse{events=$events, lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" + "ChatRetrieveResponse{events=$events, lastUpdatedAt=$lastUpdatedAt, sessionId=$sessionId, sharedAccess=$sharedAccess, generatedTitle=$generatedTitle, indexIds=$indexIds, jobMetadata=$jobMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatStreamParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatStreamParams.kt index c15de82..4563bb2 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatStreamParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/chat/ChatStreamParams.kt @@ -55,6 +55,14 @@ private constructor( */ fun prompt(): String = body.prompt() + /** + * Fail the turn if any requested index cannot be queried. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun requireAllIndexes(): Optional = body.requireAllIndexes() + /** * Returns the raw JSON value of [indexIds]. * @@ -69,6 +77,14 @@ private constructor( */ fun _prompt(): JsonField = body._prompt() + /** + * Returns the raw JSON value of [requireAllIndexes]. + * + * Unlike [requireAllIndexes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _requireAllIndexes(): JsonField = body._requireAllIndexes() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -136,6 +152,7 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [indexIds] * - [prompt] + * - [requireAllIndexes] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -169,6 +186,22 @@ private constructor( */ fun prompt(prompt: JsonField) = apply { body.prompt(prompt) } + /** Fail the turn if any requested index cannot be queried. */ + fun requireAllIndexes(requireAllIndexes: Boolean) = apply { + body.requireAllIndexes(requireAllIndexes) + } + + /** + * Sets [Builder.requireAllIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.requireAllIndexes] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requireAllIndexes(requireAllIndexes: JsonField) = apply { + body.requireAllIndexes(requireAllIndexes) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -335,6 +368,7 @@ private constructor( private constructor( private val indexIds: JsonField>, private val prompt: JsonField, + private val requireAllIndexes: JsonField, private val additionalProperties: MutableMap, ) { @@ -344,7 +378,10 @@ private constructor( @ExcludeMissing indexIds: JsonField> = JsonMissing.of(), @JsonProperty("prompt") @ExcludeMissing prompt: JsonField = JsonMissing.of(), - ) : this(indexIds, prompt, mutableMapOf()) + @JsonProperty("require_all_indexes") + @ExcludeMissing + requireAllIndexes: JsonField = JsonMissing.of(), + ) : this(indexIds, prompt, requireAllIndexes, mutableMapOf()) /** * Indexes to retrieve data from. @@ -362,6 +399,15 @@ private constructor( */ fun prompt(): String = prompt.getRequired("prompt") + /** + * Fail the turn if any requested index cannot be queried. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requireAllIndexes(): Optional = + requireAllIndexes.getOptional("require_all_indexes") + /** * Returns the raw JSON value of [indexIds]. * @@ -378,6 +424,16 @@ private constructor( */ @JsonProperty("prompt") @ExcludeMissing fun _prompt(): JsonField = prompt + /** + * Returns the raw JSON value of [requireAllIndexes]. + * + * Unlike [requireAllIndexes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("require_all_indexes") + @ExcludeMissing + fun _requireAllIndexes(): JsonField = requireAllIndexes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -409,12 +465,14 @@ private constructor( private var indexIds: JsonField>? = null private var prompt: JsonField? = null + private var requireAllIndexes: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { indexIds = body.indexIds.map { it.toMutableList() } prompt = body.prompt + requireAllIndexes = body.requireAllIndexes additionalProperties = body.additionalProperties.toMutableMap() } @@ -456,6 +514,21 @@ private constructor( */ fun prompt(prompt: JsonField) = apply { this.prompt = prompt } + /** Fail the turn if any requested index cannot be queried. */ + fun requireAllIndexes(requireAllIndexes: Boolean) = + requireAllIndexes(JsonField.of(requireAllIndexes)) + + /** + * Sets [Builder.requireAllIndexes] to an arbitrary JSON value. + * + * You should usually call [Builder.requireAllIndexes] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requireAllIndexes(requireAllIndexes: JsonField) = apply { + this.requireAllIndexes = requireAllIndexes + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -492,6 +565,7 @@ private constructor( Body( checkRequired("indexIds", indexIds).map { it.toImmutable() }, checkRequired("prompt", prompt), + requireAllIndexes, additionalProperties.toMutableMap(), ) } @@ -514,6 +588,7 @@ private constructor( indexIds() prompt() + requireAllIndexes() validated = true } @@ -533,7 +608,9 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (indexIds.asKnown().getOrNull()?.size ?: 0) + (if (prompt.asKnown().isPresent) 1 else 0) + (indexIds.asKnown().getOrNull()?.size ?: 0) + + (if (prompt.asKnown().isPresent) 1 else 0) + + (if (requireAllIndexes.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -543,15 +620,18 @@ private constructor( return other is Body && indexIds == other.indexIds && prompt == other.prompt && + requireAllIndexes == other.requireAllIndexes && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(indexIds, prompt, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(indexIds, prompt, requireAllIndexes, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{indexIds=$indexIds, prompt=$prompt, additionalProperties=$additionalProperties}" + "Body{indexIds=$indexIds, prompt=$prompt, requireAllIndexes=$requireAllIndexes, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParams.kt index 14436ae..f857cd3 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParams.kt @@ -22,7 +22,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Create a new directory within the specified project. */ +/** + * Create a new directory within the specified project. + * + * A connector subscription syncs into at most one directory. Creating a second one for the same + * subscription returns `409` with the existing directory's id in `detail.directory_id`. + */ class DirectoryCreateParams private constructor( private val organizationId: String?, diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexCreateResponse.kt index 5648394..3daccd9 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexCreateResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexCreateResponse.kt @@ -35,6 +35,7 @@ private constructor( private val lastExportedAt: JsonField, private val lastSyncedAt: JsonField, private val metadata: JsonField, + private val syncInProgress: JsonField, private val updatedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -69,6 +70,9 @@ private constructor( @ExcludeMissing lastSyncedAt: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("sync_in_progress") + @ExcludeMissing + syncInProgress: JsonField = JsonMissing.of(), @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), @@ -85,6 +89,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, mutableMapOf(), ) @@ -185,6 +190,14 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") + /** + * Whether a sync is running. Set only when getting a single index. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun syncInProgress(): Optional = syncInProgress.getOptional("sync_in_progress") + /** * Update datetime * @@ -293,6 +306,15 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [syncInProgress]. + * + * Unlike [syncInProgress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sync_in_progress") + @ExcludeMissing + fun _syncInProgress(): JsonField = syncInProgress + /** * Returns the raw JSON value of [updatedAt]. * @@ -348,6 +370,7 @@ private constructor( private var lastExportedAt: JsonField = JsonMissing.of() private var lastSyncedAt: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var syncInProgress: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -365,6 +388,7 @@ private constructor( lastExportedAt = indexCreateResponse.lastExportedAt lastSyncedAt = indexCreateResponse.lastSyncedAt metadata = indexCreateResponse.metadata + syncInProgress = indexCreateResponse.syncInProgress updatedAt = indexCreateResponse.updatedAt additionalProperties = indexCreateResponse.additionalProperties.toMutableMap() } @@ -541,6 +565,32 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Whether a sync is running. Set only when getting a single index. */ + fun syncInProgress(syncInProgress: Boolean?) = + syncInProgress(JsonField.ofNullable(syncInProgress)) + + /** + * Alias for [Builder.syncInProgress]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun syncInProgress(syncInProgress: Boolean) = syncInProgress(syncInProgress as Boolean?) + + /** Alias for calling [Builder.syncInProgress] with `syncInProgress.orElse(null)`. */ + fun syncInProgress(syncInProgress: Optional) = + syncInProgress(syncInProgress.getOrNull()) + + /** + * Sets [Builder.syncInProgress] to an arbitrary JSON value. + * + * You should usually call [Builder.syncInProgress] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun syncInProgress(syncInProgress: JsonField) = apply { + this.syncInProgress = syncInProgress + } + /** Update datetime */ fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) @@ -607,6 +657,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, additionalProperties.toMutableMap(), ) @@ -639,6 +690,7 @@ private constructor( lastExportedAt() lastSyncedAt() metadata().ifPresent { it.validate() } + syncInProgress() updatedAt() validated = true } @@ -670,6 +722,7 @@ private constructor( (if (lastExportedAt.asKnown().isPresent) 1 else 0) + (if (lastSyncedAt.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (syncInProgress.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) /** Build state and diagnostic info. */ @@ -799,6 +852,7 @@ private constructor( lastExportedAt == other.lastExportedAt && lastSyncedAt == other.lastSyncedAt && metadata == other.metadata && + syncInProgress == other.syncInProgress && updatedAt == other.updatedAt && additionalProperties == other.additionalProperties } @@ -817,6 +871,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, additionalProperties, ) @@ -825,5 +880,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IndexCreateResponse{id=$id, exportConfigId=$exportConfigId, name=$name, outputDirectoryId=$outputDirectoryId, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, syncConfigId=$syncConfigId, createdAt=$createdAt, description=$description, lastExportedAt=$lastExportedAt, lastSyncedAt=$lastSyncedAt, metadata=$metadata, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "IndexCreateResponse{id=$id, exportConfigId=$exportConfigId, name=$name, outputDirectoryId=$outputDirectoryId, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, syncConfigId=$syncConfigId, createdAt=$createdAt, description=$description, lastExportedAt=$lastExportedAt, lastSyncedAt=$lastSyncedAt, metadata=$metadata, syncInProgress=$syncInProgress, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexGetResponse.kt index 81f87e4..ca69669 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexGetResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexGetResponse.kt @@ -35,6 +35,7 @@ private constructor( private val lastExportedAt: JsonField, private val lastSyncedAt: JsonField, private val metadata: JsonField, + private val syncInProgress: JsonField, private val updatedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -69,6 +70,9 @@ private constructor( @ExcludeMissing lastSyncedAt: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("sync_in_progress") + @ExcludeMissing + syncInProgress: JsonField = JsonMissing.of(), @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), @@ -85,6 +89,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, mutableMapOf(), ) @@ -185,6 +190,14 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") + /** + * Whether a sync is running. Set only when getting a single index. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun syncInProgress(): Optional = syncInProgress.getOptional("sync_in_progress") + /** * Update datetime * @@ -293,6 +306,15 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [syncInProgress]. + * + * Unlike [syncInProgress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sync_in_progress") + @ExcludeMissing + fun _syncInProgress(): JsonField = syncInProgress + /** * Returns the raw JSON value of [updatedAt]. * @@ -348,6 +370,7 @@ private constructor( private var lastExportedAt: JsonField = JsonMissing.of() private var lastSyncedAt: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var syncInProgress: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -365,6 +388,7 @@ private constructor( lastExportedAt = indexGetResponse.lastExportedAt lastSyncedAt = indexGetResponse.lastSyncedAt metadata = indexGetResponse.metadata + syncInProgress = indexGetResponse.syncInProgress updatedAt = indexGetResponse.updatedAt additionalProperties = indexGetResponse.additionalProperties.toMutableMap() } @@ -541,6 +565,32 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Whether a sync is running. Set only when getting a single index. */ + fun syncInProgress(syncInProgress: Boolean?) = + syncInProgress(JsonField.ofNullable(syncInProgress)) + + /** + * Alias for [Builder.syncInProgress]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun syncInProgress(syncInProgress: Boolean) = syncInProgress(syncInProgress as Boolean?) + + /** Alias for calling [Builder.syncInProgress] with `syncInProgress.orElse(null)`. */ + fun syncInProgress(syncInProgress: Optional) = + syncInProgress(syncInProgress.getOrNull()) + + /** + * Sets [Builder.syncInProgress] to an arbitrary JSON value. + * + * You should usually call [Builder.syncInProgress] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun syncInProgress(syncInProgress: JsonField) = apply { + this.syncInProgress = syncInProgress + } + /** Update datetime */ fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) @@ -607,6 +657,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, additionalProperties.toMutableMap(), ) @@ -639,6 +690,7 @@ private constructor( lastExportedAt() lastSyncedAt() metadata().ifPresent { it.validate() } + syncInProgress() updatedAt() validated = true } @@ -670,6 +722,7 @@ private constructor( (if (lastExportedAt.asKnown().isPresent) 1 else 0) + (if (lastSyncedAt.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (syncInProgress.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) /** Build state and diagnostic info. */ @@ -799,6 +852,7 @@ private constructor( lastExportedAt == other.lastExportedAt && lastSyncedAt == other.lastSyncedAt && metadata == other.metadata && + syncInProgress == other.syncInProgress && updatedAt == other.updatedAt && additionalProperties == other.additionalProperties } @@ -817,6 +871,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, additionalProperties, ) @@ -825,5 +880,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IndexGetResponse{id=$id, exportConfigId=$exportConfigId, name=$name, outputDirectoryId=$outputDirectoryId, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, syncConfigId=$syncConfigId, createdAt=$createdAt, description=$description, lastExportedAt=$lastExportedAt, lastSyncedAt=$lastSyncedAt, metadata=$metadata, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "IndexGetResponse{id=$id, exportConfigId=$exportConfigId, name=$name, outputDirectoryId=$outputDirectoryId, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, syncConfigId=$syncConfigId, createdAt=$createdAt, description=$description, lastExportedAt=$lastExportedAt, lastSyncedAt=$lastSyncedAt, metadata=$metadata, syncInProgress=$syncInProgress, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexListResponse.kt index 05f57ce..b1ce1cb 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexListResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/indexes/IndexListResponse.kt @@ -35,6 +35,7 @@ private constructor( private val lastExportedAt: JsonField, private val lastSyncedAt: JsonField, private val metadata: JsonField, + private val syncInProgress: JsonField, private val updatedAt: JsonField, private val additionalProperties: MutableMap, ) { @@ -69,6 +70,9 @@ private constructor( @ExcludeMissing lastSyncedAt: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("sync_in_progress") + @ExcludeMissing + syncInProgress: JsonField = JsonMissing.of(), @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), @@ -85,6 +89,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, mutableMapOf(), ) @@ -185,6 +190,14 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") + /** + * Whether a sync is running. Set only when getting a single index. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun syncInProgress(): Optional = syncInProgress.getOptional("sync_in_progress") + /** * Update datetime * @@ -293,6 +306,15 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [syncInProgress]. + * + * Unlike [syncInProgress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sync_in_progress") + @ExcludeMissing + fun _syncInProgress(): JsonField = syncInProgress + /** * Returns the raw JSON value of [updatedAt]. * @@ -348,6 +370,7 @@ private constructor( private var lastExportedAt: JsonField = JsonMissing.of() private var lastSyncedAt: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var syncInProgress: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -365,6 +388,7 @@ private constructor( lastExportedAt = indexListResponse.lastExportedAt lastSyncedAt = indexListResponse.lastSyncedAt metadata = indexListResponse.metadata + syncInProgress = indexListResponse.syncInProgress updatedAt = indexListResponse.updatedAt additionalProperties = indexListResponse.additionalProperties.toMutableMap() } @@ -541,6 +565,32 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Whether a sync is running. Set only when getting a single index. */ + fun syncInProgress(syncInProgress: Boolean?) = + syncInProgress(JsonField.ofNullable(syncInProgress)) + + /** + * Alias for [Builder.syncInProgress]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun syncInProgress(syncInProgress: Boolean) = syncInProgress(syncInProgress as Boolean?) + + /** Alias for calling [Builder.syncInProgress] with `syncInProgress.orElse(null)`. */ + fun syncInProgress(syncInProgress: Optional) = + syncInProgress(syncInProgress.getOrNull()) + + /** + * Sets [Builder.syncInProgress] to an arbitrary JSON value. + * + * You should usually call [Builder.syncInProgress] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun syncInProgress(syncInProgress: JsonField) = apply { + this.syncInProgress = syncInProgress + } + /** Update datetime */ fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) @@ -607,6 +657,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, additionalProperties.toMutableMap(), ) @@ -639,6 +690,7 @@ private constructor( lastExportedAt() lastSyncedAt() metadata().ifPresent { it.validate() } + syncInProgress() updatedAt() validated = true } @@ -670,6 +722,7 @@ private constructor( (if (lastExportedAt.asKnown().isPresent) 1 else 0) + (if (lastSyncedAt.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (syncInProgress.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) /** Build state and diagnostic info. */ @@ -799,6 +852,7 @@ private constructor( lastExportedAt == other.lastExportedAt && lastSyncedAt == other.lastSyncedAt && metadata == other.metadata && + syncInProgress == other.syncInProgress && updatedAt == other.updatedAt && additionalProperties == other.additionalProperties } @@ -817,6 +871,7 @@ private constructor( lastExportedAt, lastSyncedAt, metadata, + syncInProgress, updatedAt, additionalProperties, ) @@ -825,5 +880,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IndexListResponse{id=$id, exportConfigId=$exportConfigId, name=$name, outputDirectoryId=$outputDirectoryId, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, syncConfigId=$syncConfigId, createdAt=$createdAt, description=$description, lastExportedAt=$lastExportedAt, lastSyncedAt=$lastSyncedAt, metadata=$metadata, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "IndexListResponse{id=$id, exportConfigId=$exportConfigId, name=$name, outputDirectoryId=$outputDirectoryId, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, syncConfigId=$syncConfigId, createdAt=$createdAt, description=$description, lastExportedAt=$lastExportedAt, lastSyncedAt=$lastSyncedAt, metadata=$metadata, syncInProgress=$syncInProgress, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitCreateParams.kt index e76a896..61dfed9 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitCreateParams.kt @@ -634,6 +634,7 @@ private constructor( private constructor( private val categories: JsonField>, private val splittingStrategy: JsonField, + private val version: JsonField, private val additionalProperties: MutableMap, ) { @@ -645,7 +646,8 @@ private constructor( @JsonProperty("splitting_strategy") @ExcludeMissing splittingStrategy: JsonField = JsonMissing.of(), - ) : this(categories, splittingStrategy, mutableMapOf()) + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + ) : this(categories, splittingStrategy, version, mutableMapOf()) /** * Categories to split documents into. @@ -664,6 +666,15 @@ private constructor( fun splittingStrategy(): Optional = splittingStrategy.getOptional("splitting_strategy") + /** + * Split version to run. Omit for the current release. Preview versions are selectable by + * name and never resolved automatically. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun version(): Optional = version.getOptional("version") + /** * Returns the raw JSON value of [categories]. * @@ -683,6 +694,13 @@ private constructor( @ExcludeMissing fun _splittingStrategy(): JsonField = splittingStrategy + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -713,12 +731,14 @@ private constructor( private var categories: JsonField>? = null private var splittingStrategy: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(configuration: Configuration) = apply { categories = configuration.categories.map { it.toMutableList() } splittingStrategy = configuration.splittingStrategy + version = configuration.version additionalProperties = configuration.additionalProperties.toMutableMap() } @@ -763,6 +783,24 @@ private constructor( this.splittingStrategy = splittingStrategy } + /** + * Split version to run. Omit for the current release. Preview versions are selectable + * by name and never resolved automatically. + */ + fun version(version: String?) = version(JsonField.ofNullable(version)) + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional) = version(version.getOrNull()) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -798,6 +836,7 @@ private constructor( Configuration( checkRequired("categories", categories).map { it.toImmutable() }, splittingStrategy, + version, additionalProperties.toMutableMap(), ) } @@ -820,6 +859,7 @@ private constructor( categories().forEach { it.validate() } splittingStrategy().ifPresent { it.validate() } + version() validated = true } @@ -840,7 +880,8 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) /** Strategy for splitting documents. */ class SplittingStrategy @@ -1295,17 +1336,18 @@ private constructor( return other is Configuration && categories == other.categories && splittingStrategy == other.splittingStrategy && + version == other.version && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(categories, splittingStrategy, additionalProperties) + Objects.hash(categories, splittingStrategy, version, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Configuration{categories=$categories, splittingStrategy=$splittingStrategy, additionalProperties=$additionalProperties}" + "Configuration{categories=$categories, splittingStrategy=$splittingStrategy, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitDocumentInput.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitDocumentInput.kt index 47a08d8..443a2a2 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitDocumentInput.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitDocumentInput.kt @@ -31,7 +31,9 @@ private constructor( ) : this(type, value, mutableMapOf()) /** - * Type of document input. Valid values are: file_id + * The beta `POST /api/v1/beta/split/jobs` endpoint accepts only `file_id`. To use a Parse job + * as input, call `POST /api/v1/split/jobs` instead, where you can pass the Parse job ID as + * `file_input`. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -100,7 +102,11 @@ private constructor( additionalProperties = splitDocumentInput.additionalProperties.toMutableMap() } - /** Type of document input. Valid values are: file_id */ + /** + * The beta `POST /api/v1/beta/split/jobs` endpoint accepts only `file_id`. To use a Parse + * job as input, call `POST /api/v1/split/jobs` instead, where you can pass the Parse job ID + * as `file_input`. + */ fun type(type: String) = type(JsonField.of(type)) /** diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitSegmentResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitSegmentResponse.kt index 66cdf6a..9552ec0 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitSegmentResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/split/SplitSegmentResponse.kt @@ -54,7 +54,7 @@ private constructor( fun confidenceCategory(): String = confidenceCategory.getRequired("confidence_category") /** - * 1-indexed page numbers in this split. + * Page numbers in this segment, as numbered by the input document. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -154,7 +154,7 @@ private constructor( this.confidenceCategory = confidenceCategory } - /** 1-indexed page numbers in this split. */ + /** Page numbers in this segment, as numbered by the input document. */ fun pages(pages: List) = pages(JsonField.of(pages)) /** diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyDeleteParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyDeleteParams.kt new file mode 100644 index 0000000..fa07273 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyDeleteParams.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.classify + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +import ai.llamaindex.llamacloud.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Delete a classify job and its result. + * + * The job must be in a terminal state (COMPLETED, FAILED, CANCELLED). Cancel a job that is still + * running before deleting it. + * + * Returns the identifiers of the deleted job. + */ +class ClassifyDeleteParams +private constructor( + private val jobId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun jobId(): Optional = Optional.ofNullable(jobId) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ClassifyDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ClassifyDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ClassifyDeleteParams]. */ + class Builder internal constructor() { + + private var jobId: String? = null + private var organizationId: String? = null + private var projectId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(classifyDeleteParams: ClassifyDeleteParams) = apply { + jobId = classifyDeleteParams.jobId + organizationId = classifyDeleteParams.organizationId + projectId = classifyDeleteParams.projectId + additionalHeaders = classifyDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = classifyDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = classifyDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ClassifyDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ClassifyDeleteParams = + ClassifyDeleteParams( + jobId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + organizationId?.let { put("organization_id", it) } + projectId?.let { put("project_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ClassifyDeleteParams && + jobId == other.jobId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + jobId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ClassifyDeleteParams{jobId=$jobId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyDeleteResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyDeleteResponse.kt new file mode 100644 index 0000000..e62c607 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyDeleteResponse.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.classify + +import ai.llamaindex.llamacloud.core.ExcludeMissing +import ai.llamaindex.llamacloud.core.JsonField +import ai.llamaindex.llamacloud.core.JsonMissing +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +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 java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Identifiers for a deleted classify job. */ +class ClassifyDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val projectId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + ) : this(id, projectId, mutableMapOf()) + + /** + * Identifier of the deleted classify job + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Project the deleted job belonged to + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun projectId(): Optional = projectId.getOptional("project_id") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + @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 [ClassifyDeleteResponse]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ClassifyDeleteResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var projectId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(classifyDeleteResponse: ClassifyDeleteResponse) = apply { + id = classifyDeleteResponse.id + projectId = classifyDeleteResponse.projectId + additionalProperties = classifyDeleteResponse.additionalProperties.toMutableMap() + } + + /** Identifier of the deleted classify job */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Project the deleted job belonged to */ + fun projectId(projectId: String?) = projectId(JsonField.ofNullable(projectId)) + + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + 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 [ClassifyDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ClassifyDeleteResponse = + ClassifyDeleteResponse( + checkRequired("id", id), + projectId, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ClassifyDeleteResponse = apply { + if (validated) { + return@apply + } + + id() + projectId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ClassifyDeleteResponse && + id == other.id && + projectId == other.projectId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, projectId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ClassifyDeleteResponse{id=$id, projectId=$projectId, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2Parameters.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2Parameters.kt index 79ceaa9..3af6d57 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2Parameters.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2Parameters.kt @@ -149,8 +149,9 @@ private constructor( fun disableCache(): Optional = disableCache.getOptional("disable_cache") /** - * Granularity of extraction: per_doc returns one object per document, per_page returns one - * object per page, per_table_row returns one object per table row + * Deprecated. Applies only to Agentic and Cost Effective versions 2.0 or earlier. Granularity + * of extraction: per_doc returns one object per document, per_page returns one object per page, + * per_table_row returns one object per table row. Agentic Plus supports per_doc only. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -234,10 +235,9 @@ private constructor( fun tier(): Optional = tier.getOptional("tier") /** - * Use 'latest' for the latest release for the selected tier or a date string (YYYY-MM-DD - * format) to pin to the nearest release at or before that date. Job responses always report the - * concrete resolved version the job runs, fixed at job creation; saved configurations keep the - * value as provided. + * Extract version name, such as '2.5'. Use 'latest' for the newest compatible release for the + * selected tier. Dates (YYYY-MM-DD) are also supported, which will use the latest version on or + * before the specified date. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -506,8 +506,10 @@ private constructor( } /** + * Deprecated. Applies only to Agentic and Cost Effective versions 2.0 or earlier. * Granularity of extraction: per_doc returns one object per document, per_page returns one - * object per page, per_table_row returns one object per table row + * object per page, per_table_row returns one object per table row. Agentic Plus supports + * per_doc only. */ fun extractionTarget(extractionTarget: ExtractionTarget) = extractionTarget(JsonField.of(extractionTarget)) @@ -690,10 +692,9 @@ private constructor( fun tier(tier: JsonField) = apply { this.tier = tier } /** - * Use 'latest' for the latest release for the selected tier or a date string (YYYY-MM-DD - * format) to pin to the nearest release at or before that date. Job responses always report - * the concrete resolved version the job runs, fixed at job creation; saved configurations - * keep the value as provided. + * Extract version name, such as '2.5'. Use 'latest' for the newest compatible release for + * the selected tier. Dates (YYYY-MM-DD) are also supported, which will use the latest + * version on or before the specified date. */ fun version(version: String) = version(JsonField.of(version)) @@ -938,8 +939,9 @@ private constructor( } /** - * Granularity of extraction: per_doc returns one object per document, per_page returns one - * object per page, per_table_row returns one object per table row + * Deprecated. Applies only to Agentic and Cost Effective versions 2.0 or earlier. Granularity + * of extraction: per_doc returns one object per document, per_page returns one object per page, + * per_table_row returns one object per table row. Agentic Plus supports per_doc only. */ class ExtractionTarget @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2Parameters.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2Parameters.kt index 56efa9d..1937eb5 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2Parameters.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2Parameters.kt @@ -142,9 +142,9 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-08-19` - * - `agentic`: `2026-09-07` - * - `agentic_plus`: `2026-08-19` + * - `cost_effective`: `2026-09-28` + * - `agentic`: `2026-09-29` + * - `agentic_plus`: `2026-09-28` * * Full list: `GET /api/v2/parse/versions`. * @@ -480,9 +480,9 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-08-19` - * - `agentic`: `2026-09-07` - * - `agentic_plus`: `2026-08-19` + * - `cost_effective`: `2026-09-28` + * - `agentic`: `2026-09-29` + * - `agentic_plus`: `2026-09-28` * * Full list: `GET /api/v2/parse/versions`. */ @@ -1011,9 +1011,9 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-08-19` - * - `agentic`: `2026-09-07` - * - `agentic_plus`: `2026-08-19` + * - `cost_effective`: `2026-09-28` + * - `agentic`: `2026-09-29` + * - `agentic_plus`: `2026-09-28` * * Full list: `GET /api/v2/parse/versions`. */ @@ -1033,9 +1033,9 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_09_07 = of("2026-09-07") + @JvmField val _2026_09_29 = of("2026-09-29") - @JvmField val _2026_08_19 = of("2026-08-19") + @JvmField val _2026_09_28 = of("2026-09-28") @JvmField val _2026_06_15 = of("2026-06-15") @@ -1045,8 +1045,8 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, - _2026_09_07, - _2026_08_19, + _2026_09_29, + _2026_09_28, _2026_06_15, } @@ -1061,8 +1061,8 @@ private constructor( */ enum class Value { LATEST, - _2026_09_07, - _2026_08_19, + _2026_09_29, + _2026_09_28, _2026_06_15, /** An enum member indicating that [Version] was instantiated with an unknown value. */ _UNKNOWN, @@ -1078,8 +1078,8 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST - _2026_09_07 -> Value._2026_09_07 - _2026_08_19 -> Value._2026_08_19 + _2026_09_29 -> Value._2026_09_29 + _2026_09_28 -> Value._2026_09_28 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN } @@ -1096,8 +1096,8 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST - _2026_09_07 -> Known._2026_09_07 - _2026_08_19 -> Known._2026_08_19 + _2026_09_29 -> Known._2026_09_29 + _2026_09_28 -> Known._2026_09_28 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") } @@ -2454,6 +2454,7 @@ private constructor( class Presentation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val includeHiddenSlides: JsonField, private val outOfBoundsContent: JsonField, private val skipEmbeddedData: JsonField, private val additionalProperties: MutableMap, @@ -2461,13 +2462,25 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("include_hidden_slides") + @ExcludeMissing + includeHiddenSlides: JsonField = JsonMissing.of(), @JsonProperty("out_of_bounds_content") @ExcludeMissing outOfBoundsContent: JsonField = JsonMissing.of(), @JsonProperty("skip_embedded_data") @ExcludeMissing skipEmbeddedData: JsonField = JsonMissing.of(), - ) : this(outOfBoundsContent, skipEmbeddedData, mutableMapOf()) + ) : this(includeHiddenSlides, outOfBoundsContent, skipEmbeddedData, mutableMapOf()) + + /** + * Include hidden PPTX slides in the output. Omitted or false skips hidden slides. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun includeHiddenSlides(): Optional = + includeHiddenSlides.getOptional("include_hidden_slides") /** * Extract content positioned outside the visible slide area. Some presentations have @@ -2489,6 +2502,16 @@ private constructor( fun skipEmbeddedData(): Optional = skipEmbeddedData.getOptional("skip_embedded_data") + /** + * Returns the raw JSON value of [includeHiddenSlides]. + * + * Unlike [includeHiddenSlides], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("include_hidden_slides") + @ExcludeMissing + fun _includeHiddenSlides(): JsonField = includeHiddenSlides + /** * Returns the raw JSON value of [outOfBoundsContent]. * @@ -2530,17 +2553,51 @@ private constructor( /** A builder for [Presentation]. */ class Builder internal constructor() { + private var includeHiddenSlides: JsonField = JsonMissing.of() private var outOfBoundsContent: JsonField = JsonMissing.of() private var skipEmbeddedData: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(presentation: Presentation) = apply { + includeHiddenSlides = presentation.includeHiddenSlides outOfBoundsContent = presentation.outOfBoundsContent skipEmbeddedData = presentation.skipEmbeddedData additionalProperties = presentation.additionalProperties.toMutableMap() } + /** + * Include hidden PPTX slides in the output. Omitted or false skips hidden slides. + */ + fun includeHiddenSlides(includeHiddenSlides: Boolean?) = + includeHiddenSlides(JsonField.ofNullable(includeHiddenSlides)) + + /** + * Alias for [Builder.includeHiddenSlides]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeHiddenSlides(includeHiddenSlides: Boolean) = + includeHiddenSlides(includeHiddenSlides as Boolean?) + + /** + * Alias for calling [Builder.includeHiddenSlides] with + * `includeHiddenSlides.orElse(null)`. + */ + fun includeHiddenSlides(includeHiddenSlides: Optional) = + includeHiddenSlides(includeHiddenSlides.getOrNull()) + + /** + * Sets [Builder.includeHiddenSlides] to an arbitrary JSON value. + * + * You should usually call [Builder.includeHiddenSlides] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun includeHiddenSlides(includeHiddenSlides: JsonField) = apply { + this.includeHiddenSlides = includeHiddenSlides + } + /** * Extract content positioned outside the visible slide area. Some presentations * have hidden notes or content that extends beyond slide boundaries @@ -2636,6 +2693,7 @@ private constructor( */ fun build(): Presentation = Presentation( + includeHiddenSlides, outOfBoundsContent, skipEmbeddedData, additionalProperties.toMutableMap(), @@ -2659,6 +2717,7 @@ private constructor( return@apply } + includeHiddenSlides() outOfBoundsContent() skipEmbeddedData() validated = true @@ -2680,7 +2739,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (outOfBoundsContent.asKnown().isPresent) 1 else 0) + + (if (includeHiddenSlides.asKnown().isPresent) 1 else 0) + + (if (outOfBoundsContent.asKnown().isPresent) 1 else 0) + (if (skipEmbeddedData.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { @@ -2689,19 +2749,25 @@ private constructor( } return other is Presentation && + includeHiddenSlides == other.includeHiddenSlides && outOfBoundsContent == other.outOfBoundsContent && skipEmbeddedData == other.skipEmbeddedData && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(outOfBoundsContent, skipEmbeddedData, additionalProperties) + Objects.hash( + includeHiddenSlides, + outOfBoundsContent, + skipEmbeddedData, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Presentation{outOfBoundsContent=$outOfBoundsContent, skipEmbeddedData=$skipEmbeddedData, additionalProperties=$additionalProperties}" + "Presentation{includeHiddenSlides=$includeHiddenSlides, outOfBoundsContent=$outOfBoundsContent, skipEmbeddedData=$skipEmbeddedData, additionalProperties=$additionalProperties}" } /** Spreadsheet parsing options (applies to .xlsx, .xls, .csv, .ods files) */ @@ -3071,6 +3137,7 @@ private constructor( private val saveOutputPdf: JsonField, private val spatialText: JsonField, private val tablesAsSpreadsheet: JsonField, + private val watermarkHandling: JsonField, private val additionalProperties: MutableMap, ) { @@ -3100,6 +3167,9 @@ private constructor( @JsonProperty("tables_as_spreadsheet") @ExcludeMissing tablesAsSpreadsheet: JsonField = JsonMissing.of(), + @JsonProperty("watermark_handling") + @ExcludeMissing + watermarkHandling: JsonField = JsonMissing.of(), ) : this( additionalOutputs, extractPrintedPageNumber, @@ -3109,6 +3179,7 @@ private constructor( saveOutputPdf, spatialText, tablesAsSpreadsheet, + watermarkHandling, mutableMapOf(), ) @@ -3204,6 +3275,21 @@ private constructor( fun tablesAsSpreadsheet(): Optional = tablesAsSpreadsheet.getOptional("tables_as_spreadsheet") + /** + * What to do with watermark text stamped across the page (e.g., 'CONFIDENTIAL', 'DRAFT'): + * 'move_to_end' (default) keeps it as the last block of the page's markdown, + * 'move_to_start' as the first block, and 'remove' drops it. The text output follows the + * same choice where the watermark is a line of its own in the PDF text layer. In every mode + * the detected text is reported in the page's `watermark` metadata. Requires version + * 2026-09-28 or later on the cost_effective, agentic, and agentic_plus tiers; ignored + * otherwise + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun watermarkHandling(): Optional = + watermarkHandling.getOptional("watermark_handling") + /** * Returns the raw JSON value of [additionalOutputs]. * @@ -3280,6 +3366,16 @@ private constructor( @ExcludeMissing fun _tablesAsSpreadsheet(): JsonField = tablesAsSpreadsheet + /** + * Returns the raw JSON value of [watermarkHandling]. + * + * Unlike [watermarkHandling], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("watermark_handling") + @ExcludeMissing + fun _watermarkHandling(): JsonField = watermarkHandling + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3309,6 +3405,7 @@ private constructor( private var saveOutputPdf: JsonField = JsonMissing.of() private var spatialText: JsonField = JsonMissing.of() private var tablesAsSpreadsheet: JsonField = JsonMissing.of() + private var watermarkHandling: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3321,6 +3418,7 @@ private constructor( saveOutputPdf = outputOptions.saveOutputPdf spatialText = outputOptions.spatialText tablesAsSpreadsheet = outputOptions.tablesAsSpreadsheet + watermarkHandling = outputOptions.watermarkHandling additionalProperties = outputOptions.additionalProperties.toMutableMap() } @@ -3539,6 +3637,35 @@ private constructor( this.tablesAsSpreadsheet = tablesAsSpreadsheet } + /** + * What to do with watermark text stamped across the page (e.g., 'CONFIDENTIAL', + * 'DRAFT'): 'move_to_end' (default) keeps it as the last block of the page's markdown, + * 'move_to_start' as the first block, and 'remove' drops it. The text output follows + * the same choice where the watermark is a line of its own in the PDF text layer. In + * every mode the detected text is reported in the page's `watermark` metadata. Requires + * version 2026-09-28 or later on the cost_effective, agentic, and agentic_plus tiers; + * ignored otherwise + */ + fun watermarkHandling(watermarkHandling: WatermarkHandling?) = + watermarkHandling(JsonField.ofNullable(watermarkHandling)) + + /** + * Alias for calling [Builder.watermarkHandling] with `watermarkHandling.orElse(null)`. + */ + fun watermarkHandling(watermarkHandling: Optional) = + watermarkHandling(watermarkHandling.getOrNull()) + + /** + * Sets [Builder.watermarkHandling] to an arbitrary JSON value. + * + * You should usually call [Builder.watermarkHandling] with a well-typed + * [WatermarkHandling] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun watermarkHandling(watermarkHandling: JsonField) = apply { + this.watermarkHandling = watermarkHandling + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3573,6 +3700,7 @@ private constructor( saveOutputPdf, spatialText, tablesAsSpreadsheet, + watermarkHandling, additionalProperties.toMutableMap(), ) } @@ -3601,6 +3729,7 @@ private constructor( saveOutputPdf() spatialText().ifPresent { it.validate() } tablesAsSpreadsheet().ifPresent { it.validate() } + watermarkHandling().ifPresent { it.validate() } validated = true } @@ -3627,7 +3756,8 @@ private constructor( (markdown.asKnown().getOrNull()?.validity() ?: 0) + (if (saveOutputPdf.asKnown().isPresent) 1 else 0) + (spatialText.asKnown().getOrNull()?.validity() ?: 0) + - (tablesAsSpreadsheet.asKnown().getOrNull()?.validity() ?: 0) + (tablesAsSpreadsheet.asKnown().getOrNull()?.validity() ?: 0) + + (watermarkHandling.asKnown().getOrNull()?.validity() ?: 0) class GranularBbox @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -5297,6 +5427,165 @@ private constructor( "TablesAsSpreadsheet{enable=$enable, guessSheetName=$guessSheetName, additionalProperties=$additionalProperties}" } + /** + * What to do with watermark text stamped across the page (e.g., 'CONFIDENTIAL', 'DRAFT'): + * 'move_to_end' (default) keeps it as the last block of the page's markdown, + * 'move_to_start' as the first block, and 'remove' drops it. The text output follows the + * same choice where the watermark is a line of its own in the PDF text layer. In every mode + * the detected text is reported in the page's `watermark` metadata. Requires version + * 2026-09-28 or later on the cost_effective, agentic, and agentic_plus tiers; ignored + * otherwise + */ + class WatermarkHandling + @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 MOVE_TO_END = of("move_to_end") + + @JvmField val MOVE_TO_START = of("move_to_start") + + @JvmField val REMOVE = of("remove") + + @JvmStatic fun of(value: String) = WatermarkHandling(JsonField.of(value)) + } + + /** An enum containing [WatermarkHandling]'s known values. */ + enum class Known { + MOVE_TO_END, + MOVE_TO_START, + REMOVE, + } + + /** + * An enum containing [WatermarkHandling]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [WatermarkHandling] 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 { + MOVE_TO_END, + MOVE_TO_START, + REMOVE, + /** + * An enum member indicating that [WatermarkHandling] 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) { + MOVE_TO_END -> Value.MOVE_TO_END + MOVE_TO_START -> Value.MOVE_TO_START + REMOVE -> Value.REMOVE + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MOVE_TO_END -> Known.MOVE_TO_END + MOVE_TO_START -> Known.MOVE_TO_START + REMOVE -> Known.REMOVE + else -> + throw LlamaCloudInvalidDataException("Unknown WatermarkHandling: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): WatermarkHandling = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 WatermarkHandling && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5311,6 +5600,7 @@ private constructor( saveOutputPdf == other.saveOutputPdf && spatialText == other.spatialText && tablesAsSpreadsheet == other.tablesAsSpreadsheet && + watermarkHandling == other.watermarkHandling && additionalProperties == other.additionalProperties } @@ -5324,6 +5614,7 @@ private constructor( saveOutputPdf, spatialText, tablesAsSpreadsheet, + watermarkHandling, additionalProperties, ) } @@ -5331,7 +5622,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OutputOptions{additionalOutputs=$additionalOutputs, extractPrintedPageNumber=$extractPrintedPageNumber, granularBboxes=$granularBboxes, imagesToSave=$imagesToSave, markdown=$markdown, saveOutputPdf=$saveOutputPdf, spatialText=$spatialText, tablesAsSpreadsheet=$tablesAsSpreadsheet, additionalProperties=$additionalProperties}" + "OutputOptions{additionalOutputs=$additionalOutputs, extractPrintedPageNumber=$extractPrintedPageNumber, granularBboxes=$granularBboxes, imagesToSave=$imagesToSave, markdown=$markdown, saveOutputPdf=$saveOutputPdf, spatialText=$spatialText, tablesAsSpreadsheet=$tablesAsSpreadsheet, watermarkHandling=$watermarkHandling, additionalProperties=$additionalProperties}" } /** Page selection: limit total pages or specify exact pages to process */ @@ -9749,9 +10040,9 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-08-19` - * - `agentic`: `2026-09-07` - * - `agentic_plus`: `2026-08-19` + * - `cost_effective`: `2026-09-28` + * - `agentic`: `2026-09-29` + * - `agentic_plus`: `2026-09-28` * * Full list: `GET /api/v2/parse/versions`. * @@ -10253,9 +10544,9 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-08-19` - * - `agentic`: `2026-09-07` - * - `agentic_plus`: `2026-08-19` + * - `cost_effective`: `2026-09-28` + * - `agentic`: `2026-09-29` + * - `agentic_plus`: `2026-09-28` * * Full list: `GET /api/v2/parse/versions`. */ @@ -11867,9 +12158,9 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-08-19` - * - `agentic`: `2026-09-07` - * - `agentic_plus`: `2026-08-19` + * - `cost_effective`: `2026-09-28` + * - `agentic`: `2026-09-29` + * - `agentic_plus`: `2026-09-28` * * Full list: `GET /api/v2/parse/versions`. */ @@ -11892,9 +12183,9 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_09_07 = of("2026-09-07") + @JvmField val _2026_09_29 = of("2026-09-29") - @JvmField val _2026_08_19 = of("2026-08-19") + @JvmField val _2026_09_28 = of("2026-09-28") @JvmField val _2026_06_15 = of("2026-06-15") @@ -11904,8 +12195,8 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, - _2026_09_07, - _2026_08_19, + _2026_09_29, + _2026_09_28, _2026_06_15, } @@ -11920,8 +12211,8 @@ private constructor( */ enum class Value { LATEST, - _2026_09_07, - _2026_08_19, + _2026_09_29, + _2026_09_28, _2026_06_15, /** * An enum member indicating that [Version] was instantiated with an unknown @@ -11940,8 +12231,8 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST - _2026_09_07 -> Value._2026_09_07 - _2026_08_19 -> Value._2026_08_19 + _2026_09_29 -> Value._2026_09_29 + _2026_09_28 -> Value._2026_09_28 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN } @@ -11958,8 +12249,8 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST - _2026_09_07 -> Known._2026_09_07 - _2026_08_19 -> Known._2026_08_19 + _2026_09_29 -> Known._2026_09_29 + _2026_09_28 -> Known._2026_09_28 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/SplitV1Parameters.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/SplitV1Parameters.kt index 2c3aaea..9557c64 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/SplitV1Parameters.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/configurations/SplitV1Parameters.kt @@ -27,7 +27,11 @@ class SplitV1Parameters private constructor( private val categories: JsonField>, private val productType: JsonValue, + private val parseConfigId: JsonField, + private val parseTier: JsonField, private val splittingStrategy: JsonField, + private val targetPages: JsonField, + private val version: JsonField, private val additionalProperties: MutableMap, ) { @@ -37,10 +41,29 @@ private constructor( @ExcludeMissing categories: JsonField> = JsonMissing.of(), @JsonProperty("product_type") @ExcludeMissing productType: JsonValue = JsonMissing.of(), + @JsonProperty("parse_config_id") + @ExcludeMissing + parseConfigId: JsonField = JsonMissing.of(), + @JsonProperty("parse_tier") + @ExcludeMissing + parseTier: JsonField = JsonMissing.of(), @JsonProperty("splitting_strategy") @ExcludeMissing splittingStrategy: JsonField = JsonMissing.of(), - ) : this(categories, productType, splittingStrategy, mutableMapOf()) + @JsonProperty("target_pages") + @ExcludeMissing + targetPages: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + ) : this( + categories, + productType, + parseConfigId, + parseTier, + splittingStrategy, + targetPages, + version, + mutableMapOf(), + ) /** * Categories to split documents into. @@ -63,6 +86,26 @@ private constructor( */ @JsonProperty("product_type") @ExcludeMissing fun _productType(): JsonValue = productType + /** + * Saved parse configuration ID to control how the document is parsed before splitting. Takes + * precedence over parse_tier. Configurations that restrict pages (`target_pages` or `max_pages` + * on the parse configuration) are rejected: split results number pages relative to the full + * document. Ignored when a completed parse job is supplied as file_input. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parseConfigId(): Optional = parseConfigId.getOptional("parse_config_id") + + /** + * Parse tier used to read the document before splitting. Defaults to fast. Ignored when a + * completed parse job is supplied as file_input. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parseTier(): Optional = parseTier.getOptional("parse_tier") + /** * Strategy for splitting documents. * @@ -72,6 +115,24 @@ private constructor( fun splittingStrategy(): Optional = splittingStrategy.getOptional("splitting_strategy") + /** + * Comma-separated page numbers or ranges to split (1-based). Pages are split in the order + * listed. Omit to split all pages. Requires a completed parse job as file_input. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun targetPages(): Optional = targetPages.getOptional("target_pages") + + /** + * Split version to run. Omit for the current release. Preview versions are selectable by name + * and never resolved automatically. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun version(): Optional = version.getOptional("version") + /** * Returns the raw JSON value of [categories]. * @@ -81,6 +142,22 @@ private constructor( @ExcludeMissing fun _categories(): JsonField> = categories + /** + * Returns the raw JSON value of [parseConfigId]. + * + * Unlike [parseConfigId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parse_config_id") + @ExcludeMissing + fun _parseConfigId(): JsonField = parseConfigId + + /** + * Returns the raw JSON value of [parseTier]. + * + * Unlike [parseTier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parse_tier") @ExcludeMissing fun _parseTier(): JsonField = parseTier + /** * Returns the raw JSON value of [splittingStrategy]. * @@ -91,6 +168,22 @@ private constructor( @ExcludeMissing fun _splittingStrategy(): JsonField = splittingStrategy + /** + * Returns the raw JSON value of [targetPages]. + * + * Unlike [targetPages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target_pages") + @ExcludeMissing + fun _targetPages(): JsonField = targetPages + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -121,14 +214,22 @@ private constructor( private var categories: JsonField>? = null private var productType: JsonValue = JsonValue.from("split_v1") + private var parseConfigId: JsonField = JsonMissing.of() + private var parseTier: JsonField = JsonMissing.of() private var splittingStrategy: JsonField = JsonMissing.of() + private var targetPages: JsonField = JsonMissing.of() + private var version: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(splitV1Parameters: SplitV1Parameters) = apply { categories = splitV1Parameters.categories.map { it.toMutableList() } productType = splitV1Parameters.productType + parseConfigId = splitV1Parameters.parseConfigId + parseTier = splitV1Parameters.parseTier splittingStrategy = splitV1Parameters.splittingStrategy + targetPages = splitV1Parameters.targetPages + version = splitV1Parameters.version additionalProperties = splitV1Parameters.additionalProperties.toMutableMap() } @@ -172,6 +273,48 @@ private constructor( */ fun productType(productType: JsonValue) = apply { this.productType = productType } + /** + * Saved parse configuration ID to control how the document is parsed before splitting. + * Takes precedence over parse_tier. Configurations that restrict pages (`target_pages` or + * `max_pages` on the parse configuration) are rejected: split results number pages relative + * to the full document. Ignored when a completed parse job is supplied as file_input. + */ + fun parseConfigId(parseConfigId: String?) = + parseConfigId(JsonField.ofNullable(parseConfigId)) + + /** Alias for calling [Builder.parseConfigId] with `parseConfigId.orElse(null)`. */ + fun parseConfigId(parseConfigId: Optional) = + parseConfigId(parseConfigId.getOrNull()) + + /** + * Sets [Builder.parseConfigId] to an arbitrary JSON value. + * + * You should usually call [Builder.parseConfigId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parseConfigId(parseConfigId: JsonField) = apply { + this.parseConfigId = parseConfigId + } + + /** + * Parse tier used to read the document before splitting. Defaults to fast. Ignored when a + * completed parse job is supplied as file_input. + */ + fun parseTier(parseTier: ParseTier?) = parseTier(JsonField.ofNullable(parseTier)) + + /** Alias for calling [Builder.parseTier] with `parseTier.orElse(null)`. */ + fun parseTier(parseTier: Optional) = parseTier(parseTier.getOrNull()) + + /** + * Sets [Builder.parseTier] to an arbitrary JSON value. + * + * You should usually call [Builder.parseTier] with a well-typed [ParseTier] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parseTier(parseTier: JsonField) = apply { this.parseTier = parseTier } + /** Strategy for splitting documents. */ fun splittingStrategy(splittingStrategy: SplittingStrategy) = splittingStrategy(JsonField.of(splittingStrategy)) @@ -187,6 +330,41 @@ private constructor( this.splittingStrategy = splittingStrategy } + /** + * Comma-separated page numbers or ranges to split (1-based). Pages are split in the order + * listed. Omit to split all pages. Requires a completed parse job as file_input. + */ + fun targetPages(targetPages: String?) = targetPages(JsonField.ofNullable(targetPages)) + + /** Alias for calling [Builder.targetPages] with `targetPages.orElse(null)`. */ + fun targetPages(targetPages: Optional) = targetPages(targetPages.getOrNull()) + + /** + * Sets [Builder.targetPages] to an arbitrary JSON value. + * + * You should usually call [Builder.targetPages] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun targetPages(targetPages: JsonField) = apply { this.targetPages = targetPages } + + /** + * Split version to run. Omit for the current release. Preview versions are selectable by + * name and never resolved automatically. + */ + fun version(version: String?) = version(JsonField.ofNullable(version)) + + /** Alias for calling [Builder.version] with `version.orElse(null)`. */ + fun version(version: Optional) = version(version.getOrNull()) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -222,7 +400,11 @@ private constructor( SplitV1Parameters( checkRequired("categories", categories).map { it.toImmutable() }, productType, + parseConfigId, + parseTier, splittingStrategy, + targetPages, + version, additionalProperties.toMutableMap(), ) } @@ -248,7 +430,11 @@ private constructor( throw LlamaCloudInvalidDataException("'productType' is invalid, received $it") } } + parseConfigId() + parseTier().ifPresent { it.validate() } splittingStrategy().ifPresent { it.validate() } + targetPages() + version() validated = true } @@ -269,7 +455,165 @@ private constructor( internal fun validity(): Int = (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + productType.let { if (it == JsonValue.from("split_v1")) 1 else 0 } + - (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + (if (parseConfigId.asKnown().isPresent) 1 else 0) + + (parseTier.asKnown().getOrNull()?.validity() ?: 0) + + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (if (targetPages.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + /** + * Parse tier used to read the document before splitting. Defaults to fast. Ignored when a + * completed parse job is supplied as file_input. + */ + class ParseTier @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 AGENTIC = of("agentic") + + @JvmField val AGENTIC_PLUS = of("agentic_plus") + + @JvmField val COST_EFFECTIVE = of("cost_effective") + + @JvmField val FAST = of("fast") + + @JvmStatic fun of(value: String) = ParseTier(JsonField.of(value)) + } + + /** An enum containing [ParseTier]'s known values. */ + enum class Known { + AGENTIC, + AGENTIC_PLUS, + COST_EFFECTIVE, + FAST, + } + + /** + * An enum containing [ParseTier]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ParseTier] 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 { + AGENTIC, + AGENTIC_PLUS, + COST_EFFECTIVE, + FAST, + /** + * An enum member indicating that [ParseTier] 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) { + AGENTIC -> Value.AGENTIC + AGENTIC_PLUS -> Value.AGENTIC_PLUS + COST_EFFECTIVE -> Value.COST_EFFECTIVE + FAST -> Value.FAST + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AGENTIC -> Known.AGENTIC + AGENTIC_PLUS -> Known.AGENTIC_PLUS + COST_EFFECTIVE -> Known.COST_EFFECTIVE + FAST -> Known.FAST + else -> throw LlamaCloudInvalidDataException("Unknown ParseTier: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ParseTier = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 ParseTier && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } /** Strategy for splitting documents. */ class SplittingStrategy @@ -715,16 +1059,29 @@ private constructor( return other is SplitV1Parameters && categories == other.categories && productType == other.productType && + parseConfigId == other.parseConfigId && + parseTier == other.parseTier && splittingStrategy == other.splittingStrategy && + targetPages == other.targetPages && + version == other.version && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(categories, productType, splittingStrategy, additionalProperties) + Objects.hash( + categories, + productType, + parseConfigId, + parseTier, + splittingStrategy, + targetPages, + version, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "SplitV1Parameters{categories=$categories, productType=$productType, splittingStrategy=$splittingStrategy, additionalProperties=$additionalProperties}" + "SplitV1Parameters{categories=$categories, productType=$productType, parseConfigId=$parseConfigId, parseTier=$parseTier, splittingStrategy=$splittingStrategy, targetPages=$targetPages, version=$version, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPage.kt new file mode 100644 index 0000000..121d038 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.datasinks + +import ai.llamaindex.llamacloud.core.AutoPager +import ai.llamaindex.llamacloud.core.Page +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.blocking.DataSinkService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see DataSinkService.listPaginated */ +class DataSinkListPaginatedPage +private constructor( + private val service: DataSinkService, + private val params: DataSinkListPaginatedParams, + private val response: DataSinkListPaginatedPageResponse, +) : Page { + + /** + * Delegates to [DataSinkListPaginatedPageResponse], but gracefully handles missing data. + * + * @see DataSinkListPaginatedPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [DataSinkListPaginatedPageResponse], but gracefully handles missing data. + * + * @see DataSinkListPaginatedPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): DataSinkListPaginatedParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): DataSinkListPaginatedPage = service.listPaginated(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): DataSinkListPaginatedParams = params + + /** The response that this page was parsed from. */ + fun response(): DataSinkListPaginatedPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DataSinkListPaginatedPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataSinkListPaginatedPage]. */ + class Builder internal constructor() { + + private var service: DataSinkService? = null + private var params: DataSinkListPaginatedParams? = null + private var response: DataSinkListPaginatedPageResponse? = null + + @JvmSynthetic + internal fun from(dataSinkListPaginatedPage: DataSinkListPaginatedPage) = apply { + service = dataSinkListPaginatedPage.service + params = dataSinkListPaginatedPage.params + response = dataSinkListPaginatedPage.response + } + + fun service(service: DataSinkService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: DataSinkListPaginatedParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DataSinkListPaginatedPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [DataSinkListPaginatedPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DataSinkListPaginatedPage = + DataSinkListPaginatedPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataSinkListPaginatedPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "DataSinkListPaginatedPage{service=$service, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPageAsync.kt new file mode 100644 index 0000000..ab8fca0 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.datasinks + +import ai.llamaindex.llamacloud.core.AutoPagerAsync +import ai.llamaindex.llamacloud.core.PageAsync +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.async.DataSinkServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see DataSinkServiceAsync.listPaginated */ +class DataSinkListPaginatedPageAsync +private constructor( + private val service: DataSinkServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: DataSinkListPaginatedParams, + private val response: DataSinkListPaginatedPageResponse, +) : PageAsync { + + /** + * Delegates to [DataSinkListPaginatedPageResponse], but gracefully handles missing data. + * + * @see DataSinkListPaginatedPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [DataSinkListPaginatedPageResponse], but gracefully handles missing data. + * + * @see DataSinkListPaginatedPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): DataSinkListPaginatedParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.listPaginated(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): DataSinkListPaginatedParams = params + + /** The response that this page was parsed from. */ + fun response(): DataSinkListPaginatedPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DataSinkListPaginatedPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataSinkListPaginatedPageAsync]. */ + class Builder internal constructor() { + + private var service: DataSinkServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: DataSinkListPaginatedParams? = null + private var response: DataSinkListPaginatedPageResponse? = null + + @JvmSynthetic + internal fun from(dataSinkListPaginatedPageAsync: DataSinkListPaginatedPageAsync) = apply { + service = dataSinkListPaginatedPageAsync.service + streamHandlerExecutor = dataSinkListPaginatedPageAsync.streamHandlerExecutor + params = dataSinkListPaginatedPageAsync.params + response = dataSinkListPaginatedPageAsync.response + } + + fun service(service: DataSinkServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: DataSinkListPaginatedParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: DataSinkListPaginatedPageResponse) = apply { + this.response = response + } + + /** + * Returns an immutable instance of [DataSinkListPaginatedPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DataSinkListPaginatedPageAsync = + DataSinkListPaginatedPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataSinkListPaginatedPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "DataSinkListPaginatedPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPageResponse.kt new file mode 100644 index 0000000..e60e0cd --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedPageResponse.kt @@ -0,0 +1,304 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.datasinks + +import ai.llamaindex.llamacloud.core.ExcludeMissing +import ai.llamaindex.llamacloud.core.JsonField +import ai.llamaindex.llamacloud.core.JsonMissing +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.checkKnown +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +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 java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Paginated list of data sinks. */ +class DataSinkListPaginatedPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val nextPageToken: JsonField, + private val totalSize: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("next_page_token") + @ExcludeMissing + nextPageToken: JsonField = JsonMissing.of(), + @JsonProperty("total_size") @ExcludeMissing totalSize: JsonField = JsonMissing.of(), + ) : this(items, nextPageToken, totalSize, mutableMapOf()) + + /** + * The list of items. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * A token, which can be sent as page_token to retrieve the next page. If this field is omitted, + * there are no subsequent pages. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextPageToken(): Optional = nextPageToken.getOptional("next_page_token") + + /** + * The total number of items available. This is only populated when specifically requested. The + * value may be an estimate and can be used for display purposes only. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalSize(): Optional = totalSize.getOptional("total_size") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [nextPageToken]. + * + * Unlike [nextPageToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_page_token") + @ExcludeMissing + fun _nextPageToken(): JsonField = nextPageToken + + /** + * Returns the raw JSON value of [totalSize]. + * + * Unlike [totalSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_size") @ExcludeMissing fun _totalSize(): JsonField = totalSize + + @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 + * [DataSinkListPaginatedPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataSinkListPaginatedPageResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var nextPageToken: JsonField = JsonMissing.of() + private var totalSize: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dataSinkListPaginatedPageResponse: DataSinkListPaginatedPageResponse) = + apply { + items = dataSinkListPaginatedPageResponse.items.map { it.toMutableList() } + nextPageToken = dataSinkListPaginatedPageResponse.nextPageToken + totalSize = dataSinkListPaginatedPageResponse.totalSize + additionalProperties = + dataSinkListPaginatedPageResponse.additionalProperties.toMutableMap() + } + + /** The list of items. */ + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [DataSink] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: DataSink) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** + * A token, which can be sent as page_token to retrieve the next page. If this field is + * omitted, there are no subsequent pages. + */ + fun nextPageToken(nextPageToken: String?) = + nextPageToken(JsonField.ofNullable(nextPageToken)) + + /** Alias for calling [Builder.nextPageToken] with `nextPageToken.orElse(null)`. */ + fun nextPageToken(nextPageToken: Optional) = + nextPageToken(nextPageToken.getOrNull()) + + /** + * Sets [Builder.nextPageToken] to an arbitrary JSON value. + * + * You should usually call [Builder.nextPageToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextPageToken(nextPageToken: JsonField) = apply { + this.nextPageToken = nextPageToken + } + + /** + * The total number of items available. This is only populated when specifically requested. + * The value may be an estimate and can be used for display purposes only. + */ + fun totalSize(totalSize: Long?) = totalSize(JsonField.ofNullable(totalSize)) + + /** + * Alias for [Builder.totalSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalSize(totalSize: Long) = totalSize(totalSize as Long?) + + /** Alias for calling [Builder.totalSize] with `totalSize.orElse(null)`. */ + fun totalSize(totalSize: Optional) = totalSize(totalSize.getOrNull()) + + /** + * Sets [Builder.totalSize] to an arbitrary JSON value. + * + * You should usually call [Builder.totalSize] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun totalSize(totalSize: JsonField) = apply { this.totalSize = totalSize } + + 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 [DataSinkListPaginatedPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DataSinkListPaginatedPageResponse = + DataSinkListPaginatedPageResponse( + checkRequired("items", items).map { it.toImmutable() }, + nextPageToken, + totalSize, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DataSinkListPaginatedPageResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + nextPageToken() + totalSize() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextPageToken.asKnown().isPresent) 1 else 0) + + (if (totalSize.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataSinkListPaginatedPageResponse && + items == other.items && + nextPageToken == other.nextPageToken && + totalSize == other.totalSize && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(items, nextPageToken, totalSize, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DataSinkListPaginatedPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedParams.kt new file mode 100644 index 0000000..0e494d3 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListPaginatedParams.kt @@ -0,0 +1,283 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.datasinks + +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List the data sinks in a project, newest first. */ +class DataSinkListPaginatedParams +private constructor( + private val includeTotal: Boolean?, + private val organizationId: String?, + private val pageSize: Long?, + private val pageToken: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Return `total_size`, a count of every row matching the filter. It is a second query on every + * page, so it is off unless asked for. + */ + fun includeTotal(): Optional = Optional.ofNullable(includeTotal) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + /** Number of items per page */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** Cursor from the previous page's `next_page_token`. */ + fun pageToken(): Optional = Optional.ofNullable(pageToken) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DataSinkListPaginatedParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DataSinkListPaginatedParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataSinkListPaginatedParams]. */ + class Builder internal constructor() { + + private var includeTotal: Boolean? = null + private var organizationId: String? = null + private var pageSize: Long? = null + private var pageToken: String? = null + private var projectId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(dataSinkListPaginatedParams: DataSinkListPaginatedParams) = apply { + includeTotal = dataSinkListPaginatedParams.includeTotal + organizationId = dataSinkListPaginatedParams.organizationId + pageSize = dataSinkListPaginatedParams.pageSize + pageToken = dataSinkListPaginatedParams.pageToken + projectId = dataSinkListPaginatedParams.projectId + additionalHeaders = dataSinkListPaginatedParams.additionalHeaders.toBuilder() + additionalQueryParams = dataSinkListPaginatedParams.additionalQueryParams.toBuilder() + } + + /** + * Return `total_size`, a count of every row matching the filter. It is a second query on + * every page, so it is off unless asked for. + */ + fun includeTotal(includeTotal: Boolean?) = apply { this.includeTotal = includeTotal } + + /** + * Alias for [Builder.includeTotal]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeTotal(includeTotal: Boolean) = includeTotal(includeTotal as Boolean?) + + /** Alias for calling [Builder.includeTotal] with `includeTotal.orElse(null)`. */ + fun includeTotal(includeTotal: Optional) = includeTotal(includeTotal.getOrNull()) + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + /** Number of items per page */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** Cursor from the previous page's `next_page_token`. */ + fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } + + /** Alias for calling [Builder.pageToken] with `pageToken.orElse(null)`. */ + fun pageToken(pageToken: Optional) = pageToken(pageToken.getOrNull()) + + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DataSinkListPaginatedParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DataSinkListPaginatedParams = + DataSinkListPaginatedParams( + includeTotal, + organizationId, + pageSize, + pageToken, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeTotal?.let { put("include_total", it.toString()) } + organizationId?.let { put("organization_id", it) } + pageSize?.let { put("page_size", it.toString()) } + pageToken?.let { put("page_token", it) } + projectId?.let { put("project_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataSinkListPaginatedParams && + includeTotal == other.includeTotal && + organizationId == other.organizationId && + pageSize == other.pageSize && + pageToken == other.pageToken && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + includeTotal, + organizationId, + pageSize, + pageToken, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DataSinkListPaginatedParams{includeTotal=$includeTotal, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListParams.kt index c4d78ba..57a861a 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/datasinks/DataSinkListParams.kt @@ -9,7 +9,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** List data sinks for a given project. */ +/** + * List a project's data sinks. Returns at most the first 50. + * + * Deprecated: use `GET /api/v1/beta/data-sinks`, which is paginated. + */ +@Deprecated("deprecated") class DataSinkListParams private constructor( private val organizationId: String?, diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfiguration.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfiguration.kt index eeb70f9..241749e 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfiguration.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfiguration.kt @@ -133,8 +133,9 @@ private constructor( fun disableCache(): Optional = disableCache.getOptional("disable_cache") /** - * Granularity of extraction: per_doc returns one object per document, per_page returns one - * object per page, per_table_row returns one object per table row + * Deprecated. Applies only to Agentic and Cost Effective versions 2.0 or earlier. Granularity + * of extraction: per_doc returns one object per document, per_page returns one object per page, + * per_table_row returns one object per table row. Agentic Plus supports per_doc only. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -218,10 +219,9 @@ private constructor( fun tier(): Optional = tier.getOptional("tier") /** - * Use 'latest' for the latest release for the selected tier or a date string (YYYY-MM-DD - * format) to pin to the nearest release at or before that date. Job responses always report the - * concrete resolved version the job runs, fixed at job creation; saved configurations keep the - * value as provided. + * Extract version name, such as '2.5'. Use 'latest' for the newest compatible release for the + * selected tier. Dates (YYYY-MM-DD) are also supported, which will use the latest version on or + * before the specified date. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -474,8 +474,10 @@ private constructor( } /** + * Deprecated. Applies only to Agentic and Cost Effective versions 2.0 or earlier. * Granularity of extraction: per_doc returns one object per document, per_page returns one - * object per page, per_table_row returns one object per table row + * object per page, per_table_row returns one object per table row. Agentic Plus supports + * per_doc only. */ fun extractionTarget(extractionTarget: ExtractionTarget) = extractionTarget(JsonField.of(extractionTarget)) @@ -658,10 +660,9 @@ private constructor( fun tier(tier: JsonField) = apply { this.tier = tier } /** - * Use 'latest' for the latest release for the selected tier or a date string (YYYY-MM-DD - * format) to pin to the nearest release at or before that date. Job responses always report - * the concrete resolved version the job runs, fixed at job creation; saved configurations - * keep the value as provided. + * Extract version name, such as '2.5'. Use 'latest' for the newest compatible release for + * the selected tier. Dates (YYYY-MM-DD) are also supported, which will use the latest + * version on or before the specified date. */ fun version(version: String) = version(JsonField.of(version)) @@ -899,8 +900,9 @@ private constructor( } /** - * Granularity of extraction: per_doc returns one object per document, per_page returns one - * object per page, per_table_row returns one object per table row + * Deprecated. Applies only to Agentic and Cost Effective versions 2.0 or earlier. Granularity + * of extraction: per_doc returns one object per document, per_page returns one object per page, + * per_table_row returns one object per table row. Agentic Plus supports per_doc only. */ class ExtractionTarget @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractDeleteParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractDeleteParams.kt index 0615458..221cfa9 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractDeleteParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractDeleteParams.kt @@ -11,10 +11,14 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Delete an extraction job and its results. */ +/** + * Delete an extraction job and its results. A non-terminal job is refused; cancel it first, or pass + * force=true to delete a job whose workflow is gone. + */ class ExtractDeleteParams private constructor( private val jobId: String?, + private val force: Boolean?, private val organizationId: String?, private val projectId: String?, private val additionalHeaders: Headers, @@ -24,6 +28,8 @@ private constructor( fun jobId(): Optional = Optional.ofNullable(jobId) + fun force(): Optional = Optional.ofNullable(force) + fun organizationId(): Optional = Optional.ofNullable(organizationId) fun projectId(): Optional = Optional.ofNullable(projectId) @@ -51,6 +57,7 @@ private constructor( class Builder internal constructor() { private var jobId: String? = null + private var force: Boolean? = null private var organizationId: String? = null private var projectId: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -60,6 +67,7 @@ private constructor( @JvmSynthetic internal fun from(extractDeleteParams: ExtractDeleteParams) = apply { jobId = extractDeleteParams.jobId + force = extractDeleteParams.force organizationId = extractDeleteParams.organizationId projectId = extractDeleteParams.projectId additionalHeaders = extractDeleteParams.additionalHeaders.toBuilder() @@ -72,6 +80,18 @@ private constructor( /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + fun force(force: Boolean?) = apply { this.force = force } + + /** + * Alias for [Builder.force]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun force(force: Boolean) = force(force as Boolean?) + + /** Alias for calling [Builder.force] with `force.orElse(null)`. */ + fun force(force: Optional) = force(force.getOrNull()) + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ @@ -211,6 +231,7 @@ private constructor( fun build(): ExtractDeleteParams = ExtractDeleteParams( jobId, + force, organizationId, projectId, additionalHeaders.build(), @@ -233,6 +254,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + force?.let { put("force", it.toString()) } organizationId?.let { put("organization_id", it) } projectId?.let { put("project_id", it) } putAll(additionalQueryParams) @@ -246,6 +268,7 @@ private constructor( return other is ExtractDeleteParams && jobId == other.jobId && + force == other.force && organizationId == other.organizationId && projectId == other.projectId && additionalHeaders == other.additionalHeaders && @@ -256,6 +279,7 @@ private constructor( override fun hashCode(): Int = Objects.hash( jobId, + force, organizationId, projectId, additionalHeaders, @@ -264,5 +288,5 @@ private constructor( ) override fun toString() = - "ExtractDeleteParams{jobId=$jobId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ExtractDeleteParams{jobId=$jobId, force=$force, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractAgent.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractAgent.kt new file mode 100644 index 0000000..0844a83 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractAgent.kt @@ -0,0 +1,2707 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.extractionagents + +import ai.llamaindex.llamacloud.core.Enum +import ai.llamaindex.llamacloud.core.ExcludeMissing +import ai.llamaindex.llamacloud.core.JsonField +import ai.llamaindex.llamacloud.core.JsonMissing +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +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 java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Schema and configuration for an extraction agent. */ +class ExtractAgent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val dataSchema: JsonField, + private val name: JsonField, + private val projectId: JsonField, + private val createdAt: JsonField, + private val customConfiguration: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), + @JsonProperty("data_schema") + @ExcludeMissing + dataSchema: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("custom_configuration") + @ExcludeMissing + customConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + config, + dataSchema, + name, + projectId, + createdAt, + customConfiguration, + updatedAt, + mutableMapOf(), + ) + + /** + * The id of the extraction agent. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The configuration parameters for the extraction agent. + * + * @throws LlamaCloudInvalidDataException 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 config(): Config = config.getRequired("config") + + /** + * The schema of the data. + * + * @throws LlamaCloudInvalidDataException 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 dataSchema(): DataSchema = dataSchema.getRequired("data_schema") + + /** + * The name of the extraction agent. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The ID of the project that the extraction agent belongs to. + * + * @throws LlamaCloudInvalidDataException 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 projectId(): String = projectId.getRequired("project_id") + + /** + * The creation time of the extraction agent. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * Custom configuration type for the extraction agent. Currently supports 'default'. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customConfiguration(): Optional = + customConfiguration.getOptional("custom_configuration") + + /** + * The last update time of the extraction agent. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [dataSchema]. + * + * Unlike [dataSchema], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_schema") + @ExcludeMissing + fun _dataSchema(): JsonField = dataSchema + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [projectId]. + * + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [customConfiguration]. + * + * Unlike [customConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_configuration") + @ExcludeMissing + fun _customConfiguration(): JsonField = customConfiguration + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @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 [ExtractAgent]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .dataSchema() + * .name() + * .projectId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtractAgent]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var config: JsonField? = null + private var dataSchema: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var customConfiguration: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(extractAgent: ExtractAgent) = apply { + id = extractAgent.id + config = extractAgent.config + dataSchema = extractAgent.dataSchema + name = extractAgent.name + projectId = extractAgent.projectId + createdAt = extractAgent.createdAt + customConfiguration = extractAgent.customConfiguration + updatedAt = extractAgent.updatedAt + additionalProperties = extractAgent.additionalProperties.toMutableMap() + } + + /** The id of the extraction agent. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The configuration parameters for the extraction agent. */ + fun config(config: Config) = config(JsonField.of(config)) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + /** The schema of the data. */ + fun dataSchema(dataSchema: DataSchema) = dataSchema(JsonField.of(dataSchema)) + + /** + * Sets [Builder.dataSchema] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSchema] with a well-typed [DataSchema] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dataSchema(dataSchema: JsonField) = apply { this.dataSchema = dataSchema } + + /** The name of the extraction agent. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The ID of the project that the extraction agent belongs to. */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) + + /** + * Sets [Builder.projectId] to an arbitrary JSON value. + * + * You should usually call [Builder.projectId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + + /** The creation time of the extraction agent. */ + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** Custom configuration type for the extraction agent. Currently supports 'default'. */ + fun customConfiguration(customConfiguration: CustomConfiguration?) = + customConfiguration(JsonField.ofNullable(customConfiguration)) + + /** + * Alias for calling [Builder.customConfiguration] with `customConfiguration.orElse(null)`. + */ + fun customConfiguration(customConfiguration: Optional) = + customConfiguration(customConfiguration.getOrNull()) + + /** + * Sets [Builder.customConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.customConfiguration] with a well-typed + * [CustomConfiguration] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun customConfiguration(customConfiguration: JsonField) = apply { + this.customConfiguration = customConfiguration + } + + /** The last update time of the extraction agent. */ + fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) + + /** Alias for calling [Builder.updatedAt] with `updatedAt.orElse(null)`. */ + fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + 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 [ExtractAgent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .dataSchema() + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExtractAgent = + ExtractAgent( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("dataSchema", dataSchema), + checkRequired("name", name), + checkRequired("projectId", projectId), + createdAt, + customConfiguration, + updatedAt, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ExtractAgent = apply { + if (validated) { + return@apply + } + + id() + config().validate() + dataSchema().validate() + name() + projectId() + createdAt() + customConfiguration().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (dataSchema.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (customConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** The configuration parameters for the extraction agent. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val chunkMode: JsonField, + private val citationBbox: JsonField, + private val citeSources: JsonField, + private val confidenceScores: JsonField, + private val extractModel: JsonField, + private val extractionMode: JsonField, + private val extractionTarget: JsonField, + private val highResolutionMode: JsonField, + private val invalidateCache: JsonField, + private val multimodalFastMode: JsonField, + private val numPagesContext: JsonField, + private val pageRange: JsonField, + private val parseModel: JsonField, + private val priority: JsonField, + private val systemPrompt: JsonField, + private val useReasoning: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("chunk_mode") + @ExcludeMissing + chunkMode: JsonField = JsonMissing.of(), + @JsonProperty("citation_bbox") + @ExcludeMissing + citationBbox: JsonField = JsonMissing.of(), + @JsonProperty("cite_sources") + @ExcludeMissing + citeSources: JsonField = JsonMissing.of(), + @JsonProperty("confidence_scores") + @ExcludeMissing + confidenceScores: JsonField = JsonMissing.of(), + @JsonProperty("extract_model") + @ExcludeMissing + extractModel: JsonField = JsonMissing.of(), + @JsonProperty("extraction_mode") + @ExcludeMissing + extractionMode: JsonField = JsonMissing.of(), + @JsonProperty("extraction_target") + @ExcludeMissing + extractionTarget: JsonField = JsonMissing.of(), + @JsonProperty("high_resolution_mode") + @ExcludeMissing + highResolutionMode: JsonField = JsonMissing.of(), + @JsonProperty("invalidate_cache") + @ExcludeMissing + invalidateCache: JsonField = JsonMissing.of(), + @JsonProperty("multimodal_fast_mode") + @ExcludeMissing + multimodalFastMode: JsonField = JsonMissing.of(), + @JsonProperty("num_pages_context") + @ExcludeMissing + numPagesContext: JsonField = JsonMissing.of(), + @JsonProperty("page_range") + @ExcludeMissing + pageRange: JsonField = JsonMissing.of(), + @JsonProperty("parse_model") + @ExcludeMissing + parseModel: JsonField = JsonMissing.of(), + @JsonProperty("priority") + @ExcludeMissing + priority: JsonField = JsonMissing.of(), + @JsonProperty("system_prompt") + @ExcludeMissing + systemPrompt: JsonField = JsonMissing.of(), + @JsonProperty("use_reasoning") + @ExcludeMissing + useReasoning: JsonField = JsonMissing.of(), + ) : this( + chunkMode, + citationBbox, + citeSources, + confidenceScores, + extractModel, + extractionMode, + extractionTarget, + highResolutionMode, + invalidateCache, + multimodalFastMode, + numPagesContext, + pageRange, + parseModel, + priority, + systemPrompt, + useReasoning, + mutableMapOf(), + ) + + /** + * The mode to use for chunking the document. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun chunkMode(): Optional = chunkMode.getOptional("chunk_mode") + + /** + * Whether to fetch citation bounding boxes for the extraction. Only available in PREMIUM + * mode. Deprecated: this is now synonymous with cite_sources. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun citationBbox(): Optional = citationBbox.getOptional("citation_bbox") + + /** + * Whether to cite sources for the extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun citeSources(): Optional = citeSources.getOptional("cite_sources") + + /** + * Whether to fetch confidence scores for the extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun confidenceScores(): Optional = + confidenceScores.getOptional("confidence_scores") + + /** + * The extract model to use for data extraction. If not provided, uses the default for the + * extraction mode. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extractModel(): Optional = extractModel.getOptional("extract_model") + + /** + * The extraction mode specified (FAST, BALANCED, MULTIMODAL, PREMIUM). + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extractionMode(): Optional = + extractionMode.getOptional("extraction_mode") + + /** + * The extraction target specified. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extractionTarget(): Optional = + extractionTarget.getOptional("extraction_target") + + /** + * Whether to use high resolution mode for the extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun highResolutionMode(): Optional = + highResolutionMode.getOptional("high_resolution_mode") + + /** + * Whether to invalidate the cache for the extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun invalidateCache(): Optional = invalidateCache.getOptional("invalidate_cache") + + /** + * DEPRECATED: Whether to use fast mode for multimodal extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun multimodalFastMode(): Optional = + multimodalFastMode.getOptional("multimodal_fast_mode") + + /** + * Number of pages to pass as context on long document extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numPagesContext(): Optional = numPagesContext.getOptional("num_pages_context") + + /** + * Comma-separated list of page numbers or ranges to extract from (1-based, e.g., + * '1,3,5-7,9' or '1-3,8-10'). + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pageRange(): Optional = pageRange.getOptional("page_range") + + /** + * Public model names. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parseModel(): Optional = parseModel.getOptional("parse_model") + + /** + * The priority for the request. This field may be ignored or overwritten depending on the + * organization tier. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priority(): Optional = priority.getOptional("priority") + + /** + * The system prompt to use for the extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun systemPrompt(): Optional = systemPrompt.getOptional("system_prompt") + + /** + * Whether to use reasoning for the extraction. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun useReasoning(): Optional = useReasoning.getOptional("use_reasoning") + + /** + * Returns the raw JSON value of [chunkMode]. + * + * Unlike [chunkMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chunk_mode") + @ExcludeMissing + fun _chunkMode(): JsonField = chunkMode + + /** + * Returns the raw JSON value of [citationBbox]. + * + * Unlike [citationBbox], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("citation_bbox") + @ExcludeMissing + fun _citationBbox(): JsonField = citationBbox + + /** + * Returns the raw JSON value of [citeSources]. + * + * Unlike [citeSources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cite_sources") + @ExcludeMissing + fun _citeSources(): JsonField = citeSources + + /** + * Returns the raw JSON value of [confidenceScores]. + * + * Unlike [confidenceScores], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("confidence_scores") + @ExcludeMissing + fun _confidenceScores(): JsonField = confidenceScores + + /** + * Returns the raw JSON value of [extractModel]. + * + * Unlike [extractModel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extract_model") + @ExcludeMissing + fun _extractModel(): JsonField = extractModel + + /** + * Returns the raw JSON value of [extractionMode]. + * + * Unlike [extractionMode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extraction_mode") + @ExcludeMissing + fun _extractionMode(): JsonField = extractionMode + + /** + * Returns the raw JSON value of [extractionTarget]. + * + * Unlike [extractionTarget], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extraction_target") + @ExcludeMissing + fun _extractionTarget(): JsonField = extractionTarget + + /** + * Returns the raw JSON value of [highResolutionMode]. + * + * Unlike [highResolutionMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("high_resolution_mode") + @ExcludeMissing + fun _highResolutionMode(): JsonField = highResolutionMode + + /** + * Returns the raw JSON value of [invalidateCache]. + * + * Unlike [invalidateCache], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("invalidate_cache") + @ExcludeMissing + fun _invalidateCache(): JsonField = invalidateCache + + /** + * Returns the raw JSON value of [multimodalFastMode]. + * + * Unlike [multimodalFastMode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multimodal_fast_mode") + @ExcludeMissing + fun _multimodalFastMode(): JsonField = multimodalFastMode + + /** + * Returns the raw JSON value of [numPagesContext]. + * + * Unlike [numPagesContext], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("num_pages_context") + @ExcludeMissing + fun _numPagesContext(): JsonField = numPagesContext + + /** + * Returns the raw JSON value of [pageRange]. + * + * Unlike [pageRange], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_range") @ExcludeMissing fun _pageRange(): JsonField = pageRange + + /** + * Returns the raw JSON value of [parseModel]. + * + * Unlike [parseModel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parse_model") + @ExcludeMissing + fun _parseModel(): JsonField = parseModel + + /** + * Returns the raw JSON value of [priority]. + * + * Unlike [priority], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("priority") @ExcludeMissing fun _priority(): JsonField = priority + + /** + * Returns the raw JSON value of [systemPrompt]. + * + * Unlike [systemPrompt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("system_prompt") + @ExcludeMissing + fun _systemPrompt(): JsonField = systemPrompt + + /** + * Returns the raw JSON value of [useReasoning]. + * + * Unlike [useReasoning], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("use_reasoning") + @ExcludeMissing + fun _useReasoning(): JsonField = useReasoning + + @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 [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var chunkMode: JsonField = JsonMissing.of() + private var citationBbox: JsonField = JsonMissing.of() + private var citeSources: JsonField = JsonMissing.of() + private var confidenceScores: JsonField = JsonMissing.of() + private var extractModel: JsonField = JsonMissing.of() + private var extractionMode: JsonField = JsonMissing.of() + private var extractionTarget: JsonField = JsonMissing.of() + private var highResolutionMode: JsonField = JsonMissing.of() + private var invalidateCache: JsonField = JsonMissing.of() + private var multimodalFastMode: JsonField = JsonMissing.of() + private var numPagesContext: JsonField = JsonMissing.of() + private var pageRange: JsonField = JsonMissing.of() + private var parseModel: JsonField = JsonMissing.of() + private var priority: JsonField = JsonMissing.of() + private var systemPrompt: JsonField = JsonMissing.of() + private var useReasoning: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + chunkMode = config.chunkMode + citationBbox = config.citationBbox + citeSources = config.citeSources + confidenceScores = config.confidenceScores + extractModel = config.extractModel + extractionMode = config.extractionMode + extractionTarget = config.extractionTarget + highResolutionMode = config.highResolutionMode + invalidateCache = config.invalidateCache + multimodalFastMode = config.multimodalFastMode + numPagesContext = config.numPagesContext + pageRange = config.pageRange + parseModel = config.parseModel + priority = config.priority + systemPrompt = config.systemPrompt + useReasoning = config.useReasoning + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** The mode to use for chunking the document. */ + fun chunkMode(chunkMode: ChunkMode) = chunkMode(JsonField.of(chunkMode)) + + /** + * Sets [Builder.chunkMode] to an arbitrary JSON value. + * + * You should usually call [Builder.chunkMode] with a well-typed [ChunkMode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun chunkMode(chunkMode: JsonField) = apply { this.chunkMode = chunkMode } + + /** + * Whether to fetch citation bounding boxes for the extraction. Only available in + * PREMIUM mode. Deprecated: this is now synonymous with cite_sources. + */ + @Deprecated("deprecated") + fun citationBbox(citationBbox: Boolean) = citationBbox(JsonField.of(citationBbox)) + + /** + * Sets [Builder.citationBbox] to an arbitrary JSON value. + * + * You should usually call [Builder.citationBbox] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun citationBbox(citationBbox: JsonField) = apply { + this.citationBbox = citationBbox + } + + /** Whether to cite sources for the extraction. */ + fun citeSources(citeSources: Boolean) = citeSources(JsonField.of(citeSources)) + + /** + * Sets [Builder.citeSources] to an arbitrary JSON value. + * + * You should usually call [Builder.citeSources] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun citeSources(citeSources: JsonField) = apply { + this.citeSources = citeSources + } + + /** Whether to fetch confidence scores for the extraction. */ + fun confidenceScores(confidenceScores: Boolean) = + confidenceScores(JsonField.of(confidenceScores)) + + /** + * Sets [Builder.confidenceScores] to an arbitrary JSON value. + * + * You should usually call [Builder.confidenceScores] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun confidenceScores(confidenceScores: JsonField) = apply { + this.confidenceScores = confidenceScores + } + + /** + * The extract model to use for data extraction. If not provided, uses the default for + * the extraction mode. + */ + fun extractModel(extractModel: ExtractModel?) = + extractModel(JsonField.ofNullable(extractModel)) + + /** Alias for calling [Builder.extractModel] with `extractModel.orElse(null)`. */ + fun extractModel(extractModel: Optional) = + extractModel(extractModel.getOrNull()) + + /** + * Sets [Builder.extractModel] to an arbitrary JSON value. + * + * You should usually call [Builder.extractModel] with a well-typed [ExtractModel] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extractModel(extractModel: JsonField) = apply { + this.extractModel = extractModel + } + + /** + * Sets [extractModel] to an arbitrary [String]. + * + * You should usually call [extractModel] with a well-typed [ExtractModel] constant + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extractModel(value: String) = extractModel(ExtractModel.of(value)) + + /** The extraction mode specified (FAST, BALANCED, MULTIMODAL, PREMIUM). */ + fun extractionMode(extractionMode: ExtractionMode) = + extractionMode(JsonField.of(extractionMode)) + + /** + * Sets [Builder.extractionMode] to an arbitrary JSON value. + * + * You should usually call [Builder.extractionMode] with a well-typed [ExtractionMode] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun extractionMode(extractionMode: JsonField) = apply { + this.extractionMode = extractionMode + } + + /** The extraction target specified. */ + fun extractionTarget(extractionTarget: ExtractionTarget) = + extractionTarget(JsonField.of(extractionTarget)) + + /** + * Sets [Builder.extractionTarget] to an arbitrary JSON value. + * + * You should usually call [Builder.extractionTarget] with a well-typed + * [ExtractionTarget] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun extractionTarget(extractionTarget: JsonField) = apply { + this.extractionTarget = extractionTarget + } + + /** Whether to use high resolution mode for the extraction. */ + fun highResolutionMode(highResolutionMode: Boolean) = + highResolutionMode(JsonField.of(highResolutionMode)) + + /** + * Sets [Builder.highResolutionMode] to an arbitrary JSON value. + * + * You should usually call [Builder.highResolutionMode] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun highResolutionMode(highResolutionMode: JsonField) = apply { + this.highResolutionMode = highResolutionMode + } + + /** Whether to invalidate the cache for the extraction. */ + fun invalidateCache(invalidateCache: Boolean) = + invalidateCache(JsonField.of(invalidateCache)) + + /** + * Sets [Builder.invalidateCache] to an arbitrary JSON value. + * + * You should usually call [Builder.invalidateCache] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invalidateCache(invalidateCache: JsonField) = apply { + this.invalidateCache = invalidateCache + } + + /** DEPRECATED: Whether to use fast mode for multimodal extraction. */ + fun multimodalFastMode(multimodalFastMode: Boolean) = + multimodalFastMode(JsonField.of(multimodalFastMode)) + + /** + * Sets [Builder.multimodalFastMode] to an arbitrary JSON value. + * + * You should usually call [Builder.multimodalFastMode] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun multimodalFastMode(multimodalFastMode: JsonField) = apply { + this.multimodalFastMode = multimodalFastMode + } + + /** Number of pages to pass as context on long document extraction. */ + fun numPagesContext(numPagesContext: Long?) = + numPagesContext(JsonField.ofNullable(numPagesContext)) + + /** + * Alias for [Builder.numPagesContext]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun numPagesContext(numPagesContext: Long) = numPagesContext(numPagesContext as Long?) + + /** Alias for calling [Builder.numPagesContext] with `numPagesContext.orElse(null)`. */ + fun numPagesContext(numPagesContext: Optional) = + numPagesContext(numPagesContext.getOrNull()) + + /** + * Sets [Builder.numPagesContext] to an arbitrary JSON value. + * + * You should usually call [Builder.numPagesContext] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numPagesContext(numPagesContext: JsonField) = apply { + this.numPagesContext = numPagesContext + } + + /** + * Comma-separated list of page numbers or ranges to extract from (1-based, e.g., + * '1,3,5-7,9' or '1-3,8-10'). + */ + fun pageRange(pageRange: String?) = pageRange(JsonField.ofNullable(pageRange)) + + /** Alias for calling [Builder.pageRange] with `pageRange.orElse(null)`. */ + fun pageRange(pageRange: Optional) = pageRange(pageRange.getOrNull()) + + /** + * Sets [Builder.pageRange] to an arbitrary JSON value. + * + * You should usually call [Builder.pageRange] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pageRange(pageRange: JsonField) = apply { this.pageRange = pageRange } + + /** Public model names. */ + fun parseModel(parseModel: ParseModel?) = parseModel(JsonField.ofNullable(parseModel)) + + /** Alias for calling [Builder.parseModel] with `parseModel.orElse(null)`. */ + fun parseModel(parseModel: Optional) = parseModel(parseModel.getOrNull()) + + /** + * Sets [Builder.parseModel] to an arbitrary JSON value. + * + * You should usually call [Builder.parseModel] with a well-typed [ParseModel] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parseModel(parseModel: JsonField) = apply { + this.parseModel = parseModel + } + + /** + * The priority for the request. This field may be ignored or overwritten depending on + * the organization tier. + */ + fun priority(priority: Priority?) = priority(JsonField.ofNullable(priority)) + + /** Alias for calling [Builder.priority] with `priority.orElse(null)`. */ + fun priority(priority: Optional) = priority(priority.getOrNull()) + + /** + * Sets [Builder.priority] to an arbitrary JSON value. + * + * You should usually call [Builder.priority] with a well-typed [Priority] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priority(priority: JsonField) = apply { this.priority = priority } + + /** The system prompt to use for the extraction. */ + fun systemPrompt(systemPrompt: String?) = + systemPrompt(JsonField.ofNullable(systemPrompt)) + + /** Alias for calling [Builder.systemPrompt] with `systemPrompt.orElse(null)`. */ + fun systemPrompt(systemPrompt: Optional) = + systemPrompt(systemPrompt.getOrNull()) + + /** + * Sets [Builder.systemPrompt] to an arbitrary JSON value. + * + * You should usually call [Builder.systemPrompt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun systemPrompt(systemPrompt: JsonField) = apply { + this.systemPrompt = systemPrompt + } + + /** Whether to use reasoning for the extraction. */ + fun useReasoning(useReasoning: Boolean) = useReasoning(JsonField.of(useReasoning)) + + /** + * Sets [Builder.useReasoning] to an arbitrary JSON value. + * + * You should usually call [Builder.useReasoning] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun useReasoning(useReasoning: JsonField) = apply { + this.useReasoning = useReasoning + } + + 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 [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = + Config( + chunkMode, + citationBbox, + citeSources, + confidenceScores, + extractModel, + extractionMode, + extractionTarget, + highResolutionMode, + invalidateCache, + multimodalFastMode, + numPagesContext, + pageRange, + parseModel, + priority, + systemPrompt, + useReasoning, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Config = apply { + if (validated) { + return@apply + } + + chunkMode().ifPresent { it.validate() } + citationBbox() + citeSources() + confidenceScores() + extractModel() + extractionMode().ifPresent { it.validate() } + extractionTarget().ifPresent { it.validate() } + highResolutionMode() + invalidateCache() + multimodalFastMode() + numPagesContext() + pageRange() + parseModel().ifPresent { it.validate() } + priority().ifPresent { it.validate() } + systemPrompt() + useReasoning() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 = + (chunkMode.asKnown().getOrNull()?.validity() ?: 0) + + (if (citationBbox.asKnown().isPresent) 1 else 0) + + (if (citeSources.asKnown().isPresent) 1 else 0) + + (if (confidenceScores.asKnown().isPresent) 1 else 0) + + (if (extractModel.asKnown().isPresent) 1 else 0) + + (extractionMode.asKnown().getOrNull()?.validity() ?: 0) + + (extractionTarget.asKnown().getOrNull()?.validity() ?: 0) + + (if (highResolutionMode.asKnown().isPresent) 1 else 0) + + (if (invalidateCache.asKnown().isPresent) 1 else 0) + + (if (multimodalFastMode.asKnown().isPresent) 1 else 0) + + (if (numPagesContext.asKnown().isPresent) 1 else 0) + + (if (pageRange.asKnown().isPresent) 1 else 0) + + (parseModel.asKnown().getOrNull()?.validity() ?: 0) + + (priority.asKnown().getOrNull()?.validity() ?: 0) + + (if (systemPrompt.asKnown().isPresent) 1 else 0) + + (if (useReasoning.asKnown().isPresent) 1 else 0) + + /** The mode to use for chunking the document. */ + class ChunkMode @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 PAGE = of("PAGE") + + @JvmField val SECTION = of("SECTION") + + @JvmStatic fun of(value: String) = ChunkMode(JsonField.of(value)) + } + + /** An enum containing [ChunkMode]'s known values. */ + enum class Known { + PAGE, + SECTION, + } + + /** + * An enum containing [ChunkMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ChunkMode] 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 { + PAGE, + SECTION, + /** + * An enum member indicating that [ChunkMode] 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) { + PAGE -> Value.PAGE + SECTION -> Value.SECTION + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PAGE -> Known.PAGE + SECTION -> Known.SECTION + else -> throw LlamaCloudInvalidDataException("Unknown ChunkMode: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ChunkMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 ChunkMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Extract model options. */ + class ExtractModel @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 GEMINI_2_0_FLASH = of("gemini-2.0-flash") + + @JvmField val GEMINI_2_5_FLASH = of("gemini-2.5-flash") + + @JvmField val GEMINI_2_5_FLASH_LITE = of("gemini-2.5-flash-lite") + + @JvmField val GEMINI_2_5_PRO = of("gemini-2.5-pro") + + @JvmField val OPENAI_GPT_4_1 = of("openai-gpt-4-1") + + @JvmField val OPENAI_GPT_4_1_MINI = of("openai-gpt-4-1-mini") + + @JvmField val OPENAI_GPT_4_1_NANO = of("openai-gpt-4-1-nano") + + @JvmField val OPENAI_GPT_4O = of("openai-gpt-4o") + + @JvmField val OPENAI_GPT_4O_MINI = of("openai-gpt-4o-mini") + + @JvmField val OPENAI_GPT_5 = of("openai-gpt-5") + + @JvmField val OPENAI_GPT_5_MINI = of("openai-gpt-5-mini") + + @JvmStatic fun of(value: String) = ExtractModel(JsonField.of(value)) + } + + /** An enum containing [ExtractModel]'s known values. */ + enum class Known { + GEMINI_2_0_FLASH, + GEMINI_2_5_FLASH, + GEMINI_2_5_FLASH_LITE, + GEMINI_2_5_PRO, + OPENAI_GPT_4_1, + OPENAI_GPT_4_1_MINI, + OPENAI_GPT_4_1_NANO, + OPENAI_GPT_4O, + OPENAI_GPT_4O_MINI, + OPENAI_GPT_5, + OPENAI_GPT_5_MINI, + } + + /** + * An enum containing [ExtractModel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExtractModel] 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 { + GEMINI_2_0_FLASH, + GEMINI_2_5_FLASH, + GEMINI_2_5_FLASH_LITE, + GEMINI_2_5_PRO, + OPENAI_GPT_4_1, + OPENAI_GPT_4_1_MINI, + OPENAI_GPT_4_1_NANO, + OPENAI_GPT_4O, + OPENAI_GPT_4O_MINI, + OPENAI_GPT_5, + OPENAI_GPT_5_MINI, + /** + * An enum member indicating that [ExtractModel] 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) { + GEMINI_2_0_FLASH -> Value.GEMINI_2_0_FLASH + GEMINI_2_5_FLASH -> Value.GEMINI_2_5_FLASH + GEMINI_2_5_FLASH_LITE -> Value.GEMINI_2_5_FLASH_LITE + GEMINI_2_5_PRO -> Value.GEMINI_2_5_PRO + OPENAI_GPT_4_1 -> Value.OPENAI_GPT_4_1 + OPENAI_GPT_4_1_MINI -> Value.OPENAI_GPT_4_1_MINI + OPENAI_GPT_4_1_NANO -> Value.OPENAI_GPT_4_1_NANO + OPENAI_GPT_4O -> Value.OPENAI_GPT_4O + OPENAI_GPT_4O_MINI -> Value.OPENAI_GPT_4O_MINI + OPENAI_GPT_5 -> Value.OPENAI_GPT_5 + OPENAI_GPT_5_MINI -> Value.OPENAI_GPT_5_MINI + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GEMINI_2_0_FLASH -> Known.GEMINI_2_0_FLASH + GEMINI_2_5_FLASH -> Known.GEMINI_2_5_FLASH + GEMINI_2_5_FLASH_LITE -> Known.GEMINI_2_5_FLASH_LITE + GEMINI_2_5_PRO -> Known.GEMINI_2_5_PRO + OPENAI_GPT_4_1 -> Known.OPENAI_GPT_4_1 + OPENAI_GPT_4_1_MINI -> Known.OPENAI_GPT_4_1_MINI + OPENAI_GPT_4_1_NANO -> Known.OPENAI_GPT_4_1_NANO + OPENAI_GPT_4O -> Known.OPENAI_GPT_4O + OPENAI_GPT_4O_MINI -> Known.OPENAI_GPT_4O_MINI + OPENAI_GPT_5 -> Known.OPENAI_GPT_5 + OPENAI_GPT_5_MINI -> Known.OPENAI_GPT_5_MINI + else -> throw LlamaCloudInvalidDataException("Unknown ExtractModel: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ExtractModel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 ExtractModel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The extraction mode specified (FAST, BALANCED, MULTIMODAL, PREMIUM). */ + class ExtractionMode + @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 BALANCED = of("BALANCED") + + @JvmField val FAST = of("FAST") + + @JvmField val MULTIMODAL = of("MULTIMODAL") + + @JvmField val PREMIUM = of("PREMIUM") + + @JvmStatic fun of(value: String) = ExtractionMode(JsonField.of(value)) + } + + /** An enum containing [ExtractionMode]'s known values. */ + enum class Known { + BALANCED, + FAST, + MULTIMODAL, + PREMIUM, + } + + /** + * An enum containing [ExtractionMode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ExtractionMode] 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 { + BALANCED, + FAST, + MULTIMODAL, + PREMIUM, + /** + * An enum member indicating that [ExtractionMode] 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) { + BALANCED -> Value.BALANCED + FAST -> Value.FAST + MULTIMODAL -> Value.MULTIMODAL + PREMIUM -> Value.PREMIUM + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + BALANCED -> Known.BALANCED + FAST -> Known.FAST + MULTIMODAL -> Known.MULTIMODAL + PREMIUM -> Known.PREMIUM + else -> throw LlamaCloudInvalidDataException("Unknown ExtractionMode: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ExtractionMode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 ExtractionMode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The extraction target specified. */ + class ExtractionTarget + @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 PER_DOC = of("PER_DOC") + + @JvmField val PER_PAGE = of("PER_PAGE") + + @JvmField val PER_TABLE_ROW = of("PER_TABLE_ROW") + + @JvmStatic fun of(value: String) = ExtractionTarget(JsonField.of(value)) + } + + /** An enum containing [ExtractionTarget]'s known values. */ + enum class Known { + PER_DOC, + PER_PAGE, + PER_TABLE_ROW, + } + + /** + * An enum containing [ExtractionTarget]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ExtractionTarget] 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 { + PER_DOC, + PER_PAGE, + PER_TABLE_ROW, + /** + * An enum member indicating that [ExtractionTarget] 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) { + PER_DOC -> Value.PER_DOC + PER_PAGE -> Value.PER_PAGE + PER_TABLE_ROW -> Value.PER_TABLE_ROW + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PER_DOC -> Known.PER_DOC + PER_PAGE -> Known.PER_PAGE + PER_TABLE_ROW -> Known.PER_TABLE_ROW + else -> throw LlamaCloudInvalidDataException("Unknown ExtractionTarget: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ExtractionTarget = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 ExtractionTarget && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Public model names. */ + class ParseModel @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 ANTHROPIC_HAIKU_3_5 = of("anthropic-haiku-3.5") + + @JvmField val ANTHROPIC_HAIKU_4_5 = of("anthropic-haiku-4.5") + + @JvmField val ANTHROPIC_SONNET_3_5 = of("anthropic-sonnet-3.5") + + @JvmField val ANTHROPIC_SONNET_3_5_V2 = of("anthropic-sonnet-3.5-v2") + + @JvmField val ANTHROPIC_SONNET_3_7 = of("anthropic-sonnet-3.7") + + @JvmField val ANTHROPIC_SONNET_4_0 = of("anthropic-sonnet-4.0") + + @JvmField val ANTHROPIC_SONNET_4_5 = of("anthropic-sonnet-4.5") + + @JvmField val GEMINI_2_0_FLASH = of("gemini-2.0-flash") + + @JvmField val GEMINI_2_0_FLASH_LITE = of("gemini-2.0-flash-lite") + + @JvmField val GEMINI_2_5_FLASH = of("gemini-2.5-flash") + + @JvmField val GEMINI_2_5_FLASH_LITE = of("gemini-2.5-flash-lite") + + @JvmField val GEMINI_2_5_PRO = of("gemini-2.5-pro") + + @JvmField val GEMINI_3_0_PRO = of("gemini-3.0-pro") + + @JvmField val GEMINI_3_1_PRO = of("gemini-3.1-pro") + + @JvmField val OPENAI_GPT_4_1 = of("openai-gpt-4-1") + + @JvmField val OPENAI_GPT_4_1_MINI = of("openai-gpt-4-1-mini") + + @JvmField val OPENAI_GPT_4_1_NANO = of("openai-gpt-4-1-nano") + + @JvmField val OPENAI_GPT_4O = of("openai-gpt-4o") + + @JvmField val OPENAI_GPT_4O_MINI = of("openai-gpt-4o-mini") + + @JvmField val OPENAI_GPT_5 = of("openai-gpt-5") + + @JvmField val OPENAI_GPT_5_MINI = of("openai-gpt-5-mini") + + @JvmField val OPENAI_GPT_5_NANO = of("openai-gpt-5-nano") + + @JvmField val OPENAI_TEXT_EMBEDDING_3_LARGE = of("openai-text-embedding-3-large") + + @JvmField val OPENAI_TEXT_EMBEDDING_3_SMALL = of("openai-text-embedding-3-small") + + @JvmField val OPENAI_WHISPER_1 = of("openai-whisper-1") + + @JvmStatic fun of(value: String) = ParseModel(JsonField.of(value)) + } + + /** An enum containing [ParseModel]'s known values. */ + enum class Known { + ANTHROPIC_HAIKU_3_5, + ANTHROPIC_HAIKU_4_5, + ANTHROPIC_SONNET_3_5, + ANTHROPIC_SONNET_3_5_V2, + ANTHROPIC_SONNET_3_7, + ANTHROPIC_SONNET_4_0, + ANTHROPIC_SONNET_4_5, + GEMINI_2_0_FLASH, + GEMINI_2_0_FLASH_LITE, + GEMINI_2_5_FLASH, + GEMINI_2_5_FLASH_LITE, + GEMINI_2_5_PRO, + GEMINI_3_0_PRO, + GEMINI_3_1_PRO, + OPENAI_GPT_4_1, + OPENAI_GPT_4_1_MINI, + OPENAI_GPT_4_1_NANO, + OPENAI_GPT_4O, + OPENAI_GPT_4O_MINI, + OPENAI_GPT_5, + OPENAI_GPT_5_MINI, + OPENAI_GPT_5_NANO, + OPENAI_TEXT_EMBEDDING_3_LARGE, + OPENAI_TEXT_EMBEDDING_3_SMALL, + OPENAI_WHISPER_1, + } + + /** + * An enum containing [ParseModel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ParseModel] 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 { + ANTHROPIC_HAIKU_3_5, + ANTHROPIC_HAIKU_4_5, + ANTHROPIC_SONNET_3_5, + ANTHROPIC_SONNET_3_5_V2, + ANTHROPIC_SONNET_3_7, + ANTHROPIC_SONNET_4_0, + ANTHROPIC_SONNET_4_5, + GEMINI_2_0_FLASH, + GEMINI_2_0_FLASH_LITE, + GEMINI_2_5_FLASH, + GEMINI_2_5_FLASH_LITE, + GEMINI_2_5_PRO, + GEMINI_3_0_PRO, + GEMINI_3_1_PRO, + OPENAI_GPT_4_1, + OPENAI_GPT_4_1_MINI, + OPENAI_GPT_4_1_NANO, + OPENAI_GPT_4O, + OPENAI_GPT_4O_MINI, + OPENAI_GPT_5, + OPENAI_GPT_5_MINI, + OPENAI_GPT_5_NANO, + OPENAI_TEXT_EMBEDDING_3_LARGE, + OPENAI_TEXT_EMBEDDING_3_SMALL, + OPENAI_WHISPER_1, + /** + * An enum member indicating that [ParseModel] 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) { + ANTHROPIC_HAIKU_3_5 -> Value.ANTHROPIC_HAIKU_3_5 + ANTHROPIC_HAIKU_4_5 -> Value.ANTHROPIC_HAIKU_4_5 + ANTHROPIC_SONNET_3_5 -> Value.ANTHROPIC_SONNET_3_5 + ANTHROPIC_SONNET_3_5_V2 -> Value.ANTHROPIC_SONNET_3_5_V2 + ANTHROPIC_SONNET_3_7 -> Value.ANTHROPIC_SONNET_3_7 + ANTHROPIC_SONNET_4_0 -> Value.ANTHROPIC_SONNET_4_0 + ANTHROPIC_SONNET_4_5 -> Value.ANTHROPIC_SONNET_4_5 + GEMINI_2_0_FLASH -> Value.GEMINI_2_0_FLASH + GEMINI_2_0_FLASH_LITE -> Value.GEMINI_2_0_FLASH_LITE + GEMINI_2_5_FLASH -> Value.GEMINI_2_5_FLASH + GEMINI_2_5_FLASH_LITE -> Value.GEMINI_2_5_FLASH_LITE + GEMINI_2_5_PRO -> Value.GEMINI_2_5_PRO + GEMINI_3_0_PRO -> Value.GEMINI_3_0_PRO + GEMINI_3_1_PRO -> Value.GEMINI_3_1_PRO + OPENAI_GPT_4_1 -> Value.OPENAI_GPT_4_1 + OPENAI_GPT_4_1_MINI -> Value.OPENAI_GPT_4_1_MINI + OPENAI_GPT_4_1_NANO -> Value.OPENAI_GPT_4_1_NANO + OPENAI_GPT_4O -> Value.OPENAI_GPT_4O + OPENAI_GPT_4O_MINI -> Value.OPENAI_GPT_4O_MINI + OPENAI_GPT_5 -> Value.OPENAI_GPT_5 + OPENAI_GPT_5_MINI -> Value.OPENAI_GPT_5_MINI + OPENAI_GPT_5_NANO -> Value.OPENAI_GPT_5_NANO + OPENAI_TEXT_EMBEDDING_3_LARGE -> Value.OPENAI_TEXT_EMBEDDING_3_LARGE + OPENAI_TEXT_EMBEDDING_3_SMALL -> Value.OPENAI_TEXT_EMBEDDING_3_SMALL + OPENAI_WHISPER_1 -> Value.OPENAI_WHISPER_1 + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ANTHROPIC_HAIKU_3_5 -> Known.ANTHROPIC_HAIKU_3_5 + ANTHROPIC_HAIKU_4_5 -> Known.ANTHROPIC_HAIKU_4_5 + ANTHROPIC_SONNET_3_5 -> Known.ANTHROPIC_SONNET_3_5 + ANTHROPIC_SONNET_3_5_V2 -> Known.ANTHROPIC_SONNET_3_5_V2 + ANTHROPIC_SONNET_3_7 -> Known.ANTHROPIC_SONNET_3_7 + ANTHROPIC_SONNET_4_0 -> Known.ANTHROPIC_SONNET_4_0 + ANTHROPIC_SONNET_4_5 -> Known.ANTHROPIC_SONNET_4_5 + GEMINI_2_0_FLASH -> Known.GEMINI_2_0_FLASH + GEMINI_2_0_FLASH_LITE -> Known.GEMINI_2_0_FLASH_LITE + GEMINI_2_5_FLASH -> Known.GEMINI_2_5_FLASH + GEMINI_2_5_FLASH_LITE -> Known.GEMINI_2_5_FLASH_LITE + GEMINI_2_5_PRO -> Known.GEMINI_2_5_PRO + GEMINI_3_0_PRO -> Known.GEMINI_3_0_PRO + GEMINI_3_1_PRO -> Known.GEMINI_3_1_PRO + OPENAI_GPT_4_1 -> Known.OPENAI_GPT_4_1 + OPENAI_GPT_4_1_MINI -> Known.OPENAI_GPT_4_1_MINI + OPENAI_GPT_4_1_NANO -> Known.OPENAI_GPT_4_1_NANO + OPENAI_GPT_4O -> Known.OPENAI_GPT_4O + OPENAI_GPT_4O_MINI -> Known.OPENAI_GPT_4O_MINI + OPENAI_GPT_5 -> Known.OPENAI_GPT_5 + OPENAI_GPT_5_MINI -> Known.OPENAI_GPT_5_MINI + OPENAI_GPT_5_NANO -> Known.OPENAI_GPT_5_NANO + OPENAI_TEXT_EMBEDDING_3_LARGE -> Known.OPENAI_TEXT_EMBEDDING_3_LARGE + OPENAI_TEXT_EMBEDDING_3_SMALL -> Known.OPENAI_TEXT_EMBEDDING_3_SMALL + OPENAI_WHISPER_1 -> Known.OPENAI_WHISPER_1 + else -> throw LlamaCloudInvalidDataException("Unknown ParseModel: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): ParseModel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 ParseModel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The priority for the request. This field may be ignored or overwritten depending on the + * organization tier. + */ + class Priority @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 CRITICAL = of("critical") + + @JvmField val HIGH = of("high") + + @JvmField val LOW = of("low") + + @JvmField val MEDIUM = of("medium") + + @JvmStatic fun of(value: String) = Priority(JsonField.of(value)) + } + + /** An enum containing [Priority]'s known values. */ + enum class Known { + CRITICAL, + HIGH, + LOW, + MEDIUM, + } + + /** + * An enum containing [Priority]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Priority] 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 { + CRITICAL, + HIGH, + LOW, + MEDIUM, + /** + * An enum member indicating that [Priority] 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) { + CRITICAL -> Value.CRITICAL + HIGH -> Value.HIGH + LOW -> Value.LOW + MEDIUM -> Value.MEDIUM + 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 LlamaCloudInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CRITICAL -> Known.CRITICAL + HIGH -> Known.HIGH + LOW -> Known.LOW + MEDIUM -> Known.MEDIUM + else -> throw LlamaCloudInvalidDataException("Unknown Priority: $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 LlamaCloudInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Priority = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 Priority && 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 Config && + chunkMode == other.chunkMode && + citationBbox == other.citationBbox && + citeSources == other.citeSources && + confidenceScores == other.confidenceScores && + extractModel == other.extractModel && + extractionMode == other.extractionMode && + extractionTarget == other.extractionTarget && + highResolutionMode == other.highResolutionMode && + invalidateCache == other.invalidateCache && + multimodalFastMode == other.multimodalFastMode && + numPagesContext == other.numPagesContext && + pageRange == other.pageRange && + parseModel == other.parseModel && + priority == other.priority && + systemPrompt == other.systemPrompt && + useReasoning == other.useReasoning && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + chunkMode, + citationBbox, + citeSources, + confidenceScores, + extractModel, + extractionMode, + extractionTarget, + highResolutionMode, + invalidateCache, + multimodalFastMode, + numPagesContext, + pageRange, + parseModel, + priority, + systemPrompt, + useReasoning, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Config{chunkMode=$chunkMode, citationBbox=$citationBbox, citeSources=$citeSources, confidenceScores=$confidenceScores, extractModel=$extractModel, extractionMode=$extractionMode, extractionTarget=$extractionTarget, highResolutionMode=$highResolutionMode, invalidateCache=$invalidateCache, multimodalFastMode=$multimodalFastMode, numPagesContext=$numPagesContext, pageRange=$pageRange, parseModel=$parseModel, priority=$priority, systemPrompt=$systemPrompt, useReasoning=$useReasoning, additionalProperties=$additionalProperties}" + } + + /** The schema of the data. */ + class DataSchema + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [DataSchema]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DataSchema]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(dataSchema: DataSchema) = apply { + additionalProperties = dataSchema.additionalProperties.toMutableMap() + } + + 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 [DataSchema]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DataSchema = DataSchema(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): DataSchema = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DataSchema && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "DataSchema{additionalProperties=$additionalProperties}" + } + + /** Custom configuration type for the extraction agent. Currently supports 'default'. */ + class CustomConfiguration + @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 DEFAULT = of("default") + + @JvmStatic fun of(value: String) = CustomConfiguration(JsonField.of(value)) + } + + /** An enum containing [CustomConfiguration]'s known values. */ + enum class Known { + DEFAULT + } + + /** + * An enum containing [CustomConfiguration]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CustomConfiguration] 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 { + DEFAULT, + /** + * An enum member indicating that [CustomConfiguration] 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) { + DEFAULT -> Value.DEFAULT + 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 LlamaCloudInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DEFAULT -> Known.DEFAULT + else -> throw LlamaCloudInvalidDataException("Unknown CustomConfiguration: $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 LlamaCloudInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CustomConfiguration = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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 CustomConfiguration && 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 ExtractAgent && + id == other.id && + config == other.config && + dataSchema == other.dataSchema && + name == other.name && + projectId == other.projectId && + createdAt == other.createdAt && + customConfiguration == other.customConfiguration && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + config, + dataSchema, + name, + projectId, + createdAt, + customConfiguration, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExtractAgent{id=$id, config=$config, dataSchema=$dataSchema, name=$name, projectId=$projectId, createdAt=$createdAt, customConfiguration=$customConfiguration, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPage.kt new file mode 100644 index 0000000..265b78e --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPage.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.extractionagents + +import ai.llamaindex.llamacloud.core.AutoPager +import ai.llamaindex.llamacloud.core.Page +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.blocking.ExtractionAgentService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see ExtractionAgentService.list */ +class ExtractionAgentListPage +private constructor( + private val service: ExtractionAgentService, + private val params: ExtractionAgentListParams, + private val response: ExtractionAgentListPageResponse, +) : Page { + + /** + * Delegates to [ExtractionAgentListPageResponse], but gracefully handles missing data. + * + * @see ExtractionAgentListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [ExtractionAgentListPageResponse], but gracefully handles missing data. + * + * @see ExtractionAgentListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): ExtractionAgentListParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): ExtractionAgentListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): ExtractionAgentListParams = params + + /** The response that this page was parsed from. */ + fun response(): ExtractionAgentListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExtractionAgentListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtractionAgentListPage]. */ + class Builder internal constructor() { + + private var service: ExtractionAgentService? = null + private var params: ExtractionAgentListParams? = null + private var response: ExtractionAgentListPageResponse? = null + + @JvmSynthetic + internal fun from(extractionAgentListPage: ExtractionAgentListPage) = apply { + service = extractionAgentListPage.service + params = extractionAgentListPage.params + response = extractionAgentListPage.response + } + + fun service(service: ExtractionAgentService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: ExtractionAgentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: ExtractionAgentListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [ExtractionAgentListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExtractionAgentListPage = + ExtractionAgentListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtractionAgentListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "ExtractionAgentListPage{service=$service, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPageAsync.kt new file mode 100644 index 0000000..6ef8162 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPageAsync.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.extractionagents + +import ai.llamaindex.llamacloud.core.AutoPagerAsync +import ai.llamaindex.llamacloud.core.PageAsync +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.async.ExtractionAgentServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see ExtractionAgentServiceAsync.list */ +class ExtractionAgentListPageAsync +private constructor( + private val service: ExtractionAgentServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: ExtractionAgentListParams, + private val response: ExtractionAgentListPageResponse, +) : PageAsync { + + /** + * Delegates to [ExtractionAgentListPageResponse], but gracefully handles missing data. + * + * @see ExtractionAgentListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [ExtractionAgentListPageResponse], but gracefully handles missing data. + * + * @see ExtractionAgentListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): ExtractionAgentListParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): ExtractionAgentListParams = params + + /** The response that this page was parsed from. */ + fun response(): ExtractionAgentListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ExtractionAgentListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtractionAgentListPageAsync]. */ + class Builder internal constructor() { + + private var service: ExtractionAgentServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: ExtractionAgentListParams? = null + private var response: ExtractionAgentListPageResponse? = null + + @JvmSynthetic + internal fun from(extractionAgentListPageAsync: ExtractionAgentListPageAsync) = apply { + service = extractionAgentListPageAsync.service + streamHandlerExecutor = extractionAgentListPageAsync.streamHandlerExecutor + params = extractionAgentListPageAsync.params + response = extractionAgentListPageAsync.response + } + + fun service(service: ExtractionAgentServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: ExtractionAgentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: ExtractionAgentListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [ExtractionAgentListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExtractionAgentListPageAsync = + ExtractionAgentListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtractionAgentListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "ExtractionAgentListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPageResponse.kt similarity index 84% rename from llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponse.kt rename to llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPageResponse.kt index 8267489..53707d2 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListPageResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package ai.llamaindex.llamacloud.models.jobdatapoints +package ai.llamaindex.llamacloud.models.extractionagents import ai.llamaindex.llamacloud.core.ExcludeMissing import ai.llamaindex.llamacloud.core.JsonField @@ -19,11 +19,11 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Paginated list of job data points. */ -class JobDataPointListPageResponse +/** Paginated list of extraction agents. */ +class ExtractionAgentListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val items: JsonField>, + private val items: JsonField>, private val nextPageToken: JsonField, private val totalSize: JsonField, private val additionalProperties: MutableMap, @@ -33,7 +33,7 @@ private constructor( private constructor( @JsonProperty("items") @ExcludeMissing - items: JsonField> = JsonMissing.of(), + items: JsonField> = JsonMissing.of(), @JsonProperty("next_page_token") @ExcludeMissing nextPageToken: JsonField = JsonMissing.of(), @@ -46,7 +46,7 @@ private constructor( * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun items(): List = items.getRequired("items") + fun items(): List = items.getRequired("items") /** * A token, which can be sent as page_token to retrieve the next page. If this field is omitted, @@ -71,7 +71,7 @@ private constructor( * * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items /** * Returns the raw JSON value of [nextPageToken]. @@ -104,7 +104,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [JobDataPointListPageResponse]. + * Returns a mutable builder for constructing an instance of + * [ExtractionAgentListPageResponse]. * * The following fields are required: * ```java @@ -114,42 +115,44 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [JobDataPointListPageResponse]. */ + /** A builder for [ExtractionAgentListPageResponse]. */ class Builder internal constructor() { - private var items: JsonField>? = null + private var items: JsonField>? = null private var nextPageToken: JsonField = JsonMissing.of() private var totalSize: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jobDataPointListPageResponse: JobDataPointListPageResponse) = apply { - items = jobDataPointListPageResponse.items.map { it.toMutableList() } - nextPageToken = jobDataPointListPageResponse.nextPageToken - totalSize = jobDataPointListPageResponse.totalSize - additionalProperties = jobDataPointListPageResponse.additionalProperties.toMutableMap() - } + internal fun from(extractionAgentListPageResponse: ExtractionAgentListPageResponse) = + apply { + items = extractionAgentListPageResponse.items.map { it.toMutableList() } + nextPageToken = extractionAgentListPageResponse.nextPageToken + totalSize = extractionAgentListPageResponse.totalSize + additionalProperties = + extractionAgentListPageResponse.additionalProperties.toMutableMap() + } /** The list of items. */ - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = items(JsonField.of(items)) /** * Sets [Builder.items] to an arbitrary JSON value. * - * You should usually call [Builder.items] with a well-typed `List` value + * You should usually call [Builder.items] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun items(items: JsonField>) = apply { + fun items(items: JsonField>) = apply { this.items = items.map { it.toMutableList() } } /** - * Adds a single [JobDataPoint] to [items]. + * Adds a single [ExtractAgent] to [items]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addItem(item: JobDataPoint) = apply { + fun addItem(item: ExtractAgent) = apply { items = (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } } @@ -220,7 +223,7 @@ private constructor( } /** - * Returns an immutable instance of [JobDataPointListPageResponse]. + * Returns an immutable instance of [ExtractionAgentListPageResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -231,8 +234,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): JobDataPointListPageResponse = - JobDataPointListPageResponse( + fun build(): ExtractionAgentListPageResponse = + ExtractionAgentListPageResponse( checkRequired("items", items).map { it.toImmutable() }, nextPageToken, totalSize, @@ -250,7 +253,7 @@ private constructor( * @throws LlamaCloudInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): JobDataPointListPageResponse = apply { + fun validate(): ExtractionAgentListPageResponse = apply { if (validated) { return@apply } @@ -285,7 +288,7 @@ private constructor( return true } - return other is JobDataPointListPageResponse && + return other is ExtractionAgentListPageResponse && items == other.items && nextPageToken == other.nextPageToken && totalSize == other.totalSize && @@ -299,5 +302,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "JobDataPointListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" + "ExtractionAgentListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListParams.kt new file mode 100644 index 0000000..d2b6770 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extractionagents/ExtractionAgentListParams.kt @@ -0,0 +1,280 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.extractionagents + +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List the extraction agents in a project, newest first. */ +class ExtractionAgentListParams +private constructor( + private val includeDefault: Boolean?, + private val organizationId: String?, + private val pageSize: Long?, + private val pageToken: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Whether to include default agents in the results */ + fun includeDefault(): Optional = Optional.ofNullable(includeDefault) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + /** Number of items per page */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** Cursor from the previous page's `next_page_token`. */ + fun pageToken(): Optional = Optional.ofNullable(pageToken) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ExtractionAgentListParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ExtractionAgentListParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtractionAgentListParams]. */ + class Builder internal constructor() { + + private var includeDefault: Boolean? = null + private var organizationId: String? = null + private var pageSize: Long? = null + private var pageToken: String? = null + private var projectId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(extractionAgentListParams: ExtractionAgentListParams) = apply { + includeDefault = extractionAgentListParams.includeDefault + organizationId = extractionAgentListParams.organizationId + pageSize = extractionAgentListParams.pageSize + pageToken = extractionAgentListParams.pageToken + projectId = extractionAgentListParams.projectId + additionalHeaders = extractionAgentListParams.additionalHeaders.toBuilder() + additionalQueryParams = extractionAgentListParams.additionalQueryParams.toBuilder() + } + + /** Whether to include default agents in the results */ + fun includeDefault(includeDefault: Boolean?) = apply { + this.includeDefault = includeDefault + } + + /** + * Alias for [Builder.includeDefault]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeDefault(includeDefault: Boolean) = includeDefault(includeDefault as Boolean?) + + /** Alias for calling [Builder.includeDefault] with `includeDefault.orElse(null)`. */ + fun includeDefault(includeDefault: Optional) = + includeDefault(includeDefault.getOrNull()) + + fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.getOrNull()) + + /** Number of items per page */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** Cursor from the previous page's `next_page_token`. */ + fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } + + /** Alias for calling [Builder.pageToken] with `pageToken.orElse(null)`. */ + fun pageToken(pageToken: Optional) = pageToken(pageToken.getOrNull()) + + fun projectId(projectId: String?) = apply { this.projectId = projectId } + + /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ + fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ExtractionAgentListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExtractionAgentListParams = + ExtractionAgentListParams( + includeDefault, + organizationId, + pageSize, + pageToken, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + includeDefault?.let { put("include_default", it.toString()) } + organizationId?.let { put("organization_id", it) } + pageSize?.let { put("page_size", it.toString()) } + pageToken?.let { put("page_token", it) } + projectId?.let { put("project_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExtractionAgentListParams && + includeDefault == other.includeDefault && + organizationId == other.organizationId && + pageSize == other.pageSize && + pageToken == other.pageToken && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + includeDefault, + organizationId, + pageSize, + pageToken, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ExtractionAgentListParams{includeDefault=$includeDefault, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPoint.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPoint.kt deleted file mode 100644 index cd5a243..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPoint.kt +++ /dev/null @@ -1,879 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.jobdatapoints - -import ai.llamaindex.llamacloud.core.ExcludeMissing -import ai.llamaindex.llamacloud.core.JsonField -import ai.llamaindex.llamacloud.core.JsonMissing -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException -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 java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** A job data point. */ -class JobDataPoint -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val createdAt: JsonField, - private val customTag: JsonField, - private val projectId: JsonField, - private val status: JsonField, - private val updatedAt: JsonField, - private val errorMessage: JsonField, - private val stateTransitions: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("custom_tag") @ExcludeMissing customTag: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("state_transitions") - @ExcludeMissing - stateTransitions: JsonField = JsonMissing.of(), - ) : this( - id, - createdAt, - customTag, - projectId, - status, - updatedAt, - errorMessage, - stateTransitions, - mutableMapOf(), - ) - - /** - * Job ID. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * Created timestamp. - * - * @throws LlamaCloudInvalidDataException 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 createdAt(): OffsetDateTime = createdAt.getRequired("created_at") - - /** - * Custom tag. - * - * @throws LlamaCloudInvalidDataException 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 customTag(): String = customTag.getRequired("custom_tag") - - /** - * Project ID. - * - * @throws LlamaCloudInvalidDataException 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 projectId(): String = projectId.getRequired("project_id") - - /** - * Job status. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): String = status.getRequired("status") - - /** - * Updated timestamp. - * - * @throws LlamaCloudInvalidDataException 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 updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") - - /** - * Error message, if any. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun errorMessage(): Optional = errorMessage.getOptional("error_message") - - /** - * Job state transition timestamps. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun stateTransitions(): Optional = - stateTransitions.getOptional("state_transitions") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") - @ExcludeMissing - fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [customTag]. - * - * Unlike [customTag], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("custom_tag") @ExcludeMissing fun _customTag(): JsonField = customTag - - /** - * Returns the raw JSON value of [projectId]. - * - * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated_at") - @ExcludeMissing - fun _updatedAt(): JsonField = updatedAt - - /** - * Returns the raw JSON value of [errorMessage]. - * - * Unlike [errorMessage], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("error_message") - @ExcludeMissing - fun _errorMessage(): JsonField = errorMessage - - /** - * Returns the raw JSON value of [stateTransitions]. - * - * Unlike [stateTransitions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("state_transitions") - @ExcludeMissing - fun _stateTransitions(): JsonField = stateTransitions - - @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 [JobDataPoint]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .customTag() - * .projectId() - * .status() - * .updatedAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobDataPoint]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var customTag: JsonField? = null - private var projectId: JsonField? = null - private var status: JsonField? = null - private var updatedAt: JsonField? = null - private var errorMessage: JsonField = JsonMissing.of() - private var stateTransitions: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(jobDataPoint: JobDataPoint) = apply { - id = jobDataPoint.id - createdAt = jobDataPoint.createdAt - customTag = jobDataPoint.customTag - projectId = jobDataPoint.projectId - status = jobDataPoint.status - updatedAt = jobDataPoint.updatedAt - errorMessage = jobDataPoint.errorMessage - stateTransitions = jobDataPoint.stateTransitions - additionalProperties = jobDataPoint.additionalProperties.toMutableMap() - } - - /** Job ID. */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** Created timestamp. */ - fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** Custom tag. */ - fun customTag(customTag: String) = customTag(JsonField.of(customTag)) - - /** - * Sets [Builder.customTag] to an arbitrary JSON value. - * - * You should usually call [Builder.customTag] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun customTag(customTag: JsonField) = apply { this.customTag = customTag } - - /** Project ID. */ - fun projectId(projectId: String) = projectId(JsonField.of(projectId)) - - /** - * Sets [Builder.projectId] to an arbitrary JSON value. - * - * You should usually call [Builder.projectId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - - /** Job status. */ - fun status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Updated timestamp. */ - fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - /** Error message, if any. */ - fun errorMessage(errorMessage: String?) = errorMessage(JsonField.ofNullable(errorMessage)) - - /** Alias for calling [Builder.errorMessage] with `errorMessage.orElse(null)`. */ - fun errorMessage(errorMessage: Optional) = errorMessage(errorMessage.getOrNull()) - - /** - * Sets [Builder.errorMessage] to an arbitrary JSON value. - * - * You should usually call [Builder.errorMessage] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun errorMessage(errorMessage: JsonField) = apply { - this.errorMessage = errorMessage - } - - /** Job state transition timestamps. */ - fun stateTransitions(stateTransitions: StateTransitions) = - stateTransitions(JsonField.of(stateTransitions)) - - /** - * Sets [Builder.stateTransitions] to an arbitrary JSON value. - * - * You should usually call [Builder.stateTransitions] with a well-typed [StateTransitions] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun stateTransitions(stateTransitions: JsonField) = apply { - this.stateTransitions = stateTransitions - } - - 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 [JobDataPoint]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .customTag() - * .projectId() - * .status() - * .updatedAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): JobDataPoint = - JobDataPoint( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("customTag", customTag), - checkRequired("projectId", projectId), - checkRequired("status", status), - checkRequired("updatedAt", updatedAt), - errorMessage, - stateTransitions, - 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): JobDataPoint = apply { - if (validated) { - return@apply - } - - id() - createdAt() - customTag() - projectId() - status() - updatedAt() - errorMessage() - stateTransitions().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LlamaCloudInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (customTag.asKnown().isPresent) 1 else 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (stateTransitions.asKnown().getOrNull()?.validity() ?: 0) - - /** Job state transition timestamps. */ - class StateTransitions - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val cancelledAt: JsonField, - private val completedAt: JsonField, - private val failedAt: JsonField, - private val pendingAt: JsonField, - private val runningAt: JsonField, - private val throttledAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cancelled_at") - @ExcludeMissing - cancelledAt: JsonField = JsonMissing.of(), - @JsonProperty("completed_at") - @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - @JsonProperty("failed_at") - @ExcludeMissing - failedAt: JsonField = JsonMissing.of(), - @JsonProperty("pending_at") - @ExcludeMissing - pendingAt: JsonField = JsonMissing.of(), - @JsonProperty("running_at") - @ExcludeMissing - runningAt: JsonField = JsonMissing.of(), - @JsonProperty("throttled_at") - @ExcludeMissing - throttledAt: JsonField = JsonMissing.of(), - ) : this( - cancelledAt, - completedAt, - failedAt, - pendingAt, - runningAt, - throttledAt, - mutableMapOf(), - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun cancelledAt(): Optional = cancelledAt.getOptional("cancelled_at") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun completedAt(): Optional = completedAt.getOptional("completed_at") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun failedAt(): Optional = failedAt.getOptional("failed_at") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pendingAt(): Optional = pendingAt.getOptional("pending_at") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun runningAt(): Optional = runningAt.getOptional("running_at") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun throttledAt(): Optional = throttledAt.getOptional("throttled_at") - - /** - * Returns the raw JSON value of [cancelledAt]. - * - * Unlike [cancelledAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cancelled_at") - @ExcludeMissing - fun _cancelledAt(): JsonField = cancelledAt - - /** - * Returns the raw JSON value of [completedAt]. - * - * Unlike [completedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("completed_at") - @ExcludeMissing - fun _completedAt(): JsonField = completedAt - - /** - * Returns the raw JSON value of [failedAt]. - * - * Unlike [failedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("failed_at") - @ExcludeMissing - fun _failedAt(): JsonField = failedAt - - /** - * Returns the raw JSON value of [pendingAt]. - * - * Unlike [pendingAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pending_at") - @ExcludeMissing - fun _pendingAt(): JsonField = pendingAt - - /** - * Returns the raw JSON value of [runningAt]. - * - * Unlike [runningAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("running_at") - @ExcludeMissing - fun _runningAt(): JsonField = runningAt - - /** - * Returns the raw JSON value of [throttledAt]. - * - * Unlike [throttledAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("throttled_at") - @ExcludeMissing - fun _throttledAt(): JsonField = throttledAt - - @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 [StateTransitions]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StateTransitions]. */ - class Builder internal constructor() { - - private var cancelledAt: JsonField = JsonMissing.of() - private var completedAt: JsonField = JsonMissing.of() - private var failedAt: JsonField = JsonMissing.of() - private var pendingAt: JsonField = JsonMissing.of() - private var runningAt: JsonField = JsonMissing.of() - private var throttledAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(stateTransitions: StateTransitions) = apply { - cancelledAt = stateTransitions.cancelledAt - completedAt = stateTransitions.completedAt - failedAt = stateTransitions.failedAt - pendingAt = stateTransitions.pendingAt - runningAt = stateTransitions.runningAt - throttledAt = stateTransitions.throttledAt - additionalProperties = stateTransitions.additionalProperties.toMutableMap() - } - - fun cancelledAt(cancelledAt: OffsetDateTime?) = - cancelledAt(JsonField.ofNullable(cancelledAt)) - - /** Alias for calling [Builder.cancelledAt] with `cancelledAt.orElse(null)`. */ - fun cancelledAt(cancelledAt: Optional) = - cancelledAt(cancelledAt.getOrNull()) - - /** - * Sets [Builder.cancelledAt] to an arbitrary JSON value. - * - * You should usually call [Builder.cancelledAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun cancelledAt(cancelledAt: JsonField) = apply { - this.cancelledAt = cancelledAt - } - - fun completedAt(completedAt: OffsetDateTime?) = - completedAt(JsonField.ofNullable(completedAt)) - - /** Alias for calling [Builder.completedAt] with `completedAt.orElse(null)`. */ - fun completedAt(completedAt: Optional) = - completedAt(completedAt.getOrNull()) - - /** - * Sets [Builder.completedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.completedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun completedAt(completedAt: JsonField) = apply { - this.completedAt = completedAt - } - - fun failedAt(failedAt: OffsetDateTime?) = failedAt(JsonField.ofNullable(failedAt)) - - /** Alias for calling [Builder.failedAt] with `failedAt.orElse(null)`. */ - fun failedAt(failedAt: Optional) = failedAt(failedAt.getOrNull()) - - /** - * Sets [Builder.failedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.failedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun failedAt(failedAt: JsonField) = apply { this.failedAt = failedAt } - - fun pendingAt(pendingAt: OffsetDateTime?) = pendingAt(JsonField.ofNullable(pendingAt)) - - /** Alias for calling [Builder.pendingAt] with `pendingAt.orElse(null)`. */ - fun pendingAt(pendingAt: Optional) = pendingAt(pendingAt.getOrNull()) - - /** - * Sets [Builder.pendingAt] to an arbitrary JSON value. - * - * You should usually call [Builder.pendingAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pendingAt(pendingAt: JsonField) = apply { - this.pendingAt = pendingAt - } - - fun runningAt(runningAt: OffsetDateTime?) = runningAt(JsonField.ofNullable(runningAt)) - - /** Alias for calling [Builder.runningAt] with `runningAt.orElse(null)`. */ - fun runningAt(runningAt: Optional) = runningAt(runningAt.getOrNull()) - - /** - * Sets [Builder.runningAt] to an arbitrary JSON value. - * - * You should usually call [Builder.runningAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun runningAt(runningAt: JsonField) = apply { - this.runningAt = runningAt - } - - fun throttledAt(throttledAt: OffsetDateTime?) = - throttledAt(JsonField.ofNullable(throttledAt)) - - /** Alias for calling [Builder.throttledAt] with `throttledAt.orElse(null)`. */ - fun throttledAt(throttledAt: Optional) = - throttledAt(throttledAt.getOrNull()) - - /** - * Sets [Builder.throttledAt] to an arbitrary JSON value. - * - * You should usually call [Builder.throttledAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun throttledAt(throttledAt: JsonField) = apply { - this.throttledAt = throttledAt - } - - 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 [StateTransitions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): StateTransitions = - StateTransitions( - cancelledAt, - completedAt, - failedAt, - pendingAt, - runningAt, - throttledAt, - 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 LlamaCloudInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): StateTransitions = apply { - if (validated) { - return@apply - } - - cancelledAt() - completedAt() - failedAt() - pendingAt() - runningAt() - throttledAt() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LlamaCloudInvalidDataException) { - 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 (cancelledAt.asKnown().isPresent) 1 else 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) + - (if (failedAt.asKnown().isPresent) 1 else 0) + - (if (pendingAt.asKnown().isPresent) 1 else 0) + - (if (runningAt.asKnown().isPresent) 1 else 0) + - (if (throttledAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StateTransitions && - cancelledAt == other.cancelledAt && - completedAt == other.completedAt && - failedAt == other.failedAt && - pendingAt == other.pendingAt && - runningAt == other.runningAt && - throttledAt == other.throttledAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - cancelledAt, - completedAt, - failedAt, - pendingAt, - runningAt, - throttledAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StateTransitions{cancelledAt=$cancelledAt, completedAt=$completedAt, failedAt=$failedAt, pendingAt=$pendingAt, runningAt=$runningAt, throttledAt=$throttledAt, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobDataPoint && - id == other.id && - createdAt == other.createdAt && - customTag == other.customTag && - projectId == other.projectId && - status == other.status && - updatedAt == other.updatedAt && - errorMessage == other.errorMessage && - stateTransitions == other.stateTransitions && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - customTag, - projectId, - status, - updatedAt, - errorMessage, - stateTransitions, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "JobDataPoint{id=$id, createdAt=$createdAt, customTag=$customTag, projectId=$projectId, status=$status, updatedAt=$updatedAt, errorMessage=$errorMessage, stateTransitions=$stateTransitions, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParams.kt deleted file mode 100644 index 07dfb34..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParams.kt +++ /dev/null @@ -1,525 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.jobdatapoints - -import ai.llamaindex.llamacloud.core.Enum -import ai.llamaindex.llamacloud.core.JsonField -import ai.llamaindex.llamacloud.core.Params -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -import ai.llamaindex.llamacloud.core.toImmutable -import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator -import java.time.OffsetDateTime -import java.time.format.DateTimeFormatter -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns paginated job data points for the current project. */ -class JobDataPointListParams -private constructor( - private val jobType: JobType, - private val createdAtOnOrAfter: OffsetDateTime?, - private val createdAtOnOrBefore: OffsetDateTime?, - private val hours: Long?, - private val organizationId: String?, - private val pageSize: Long?, - private val pageToken: String?, - private val projectId: String?, - private val status: List?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** Job type to query. */ - fun jobType(): JobType = jobType - - /** Include items created at or after this timestamp (inclusive) */ - fun createdAtOnOrAfter(): Optional = Optional.ofNullable(createdAtOnOrAfter) - - /** Include items created at or before this timestamp (inclusive) */ - fun createdAtOnOrBefore(): Optional = Optional.ofNullable(createdAtOnOrBefore) - - /** Hours of history to include. */ - fun hours(): Optional = Optional.ofNullable(hours) - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - /** Number of items per page. */ - fun pageSize(): Optional = Optional.ofNullable(pageSize) - - /** Cursor token for the next page. */ - fun pageToken(): Optional = Optional.ofNullable(pageToken) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - /** Filter by status. */ - fun status(): Optional> = Optional.ofNullable(status) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [JobDataPointListParams]. - * - * The following fields are required: - * ```java - * .jobType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobDataPointListParams]. */ - class Builder internal constructor() { - - private var jobType: JobType? = null - private var createdAtOnOrAfter: OffsetDateTime? = null - private var createdAtOnOrBefore: OffsetDateTime? = null - private var hours: Long? = null - private var organizationId: String? = null - private var pageSize: Long? = null - private var pageToken: String? = null - private var projectId: String? = null - private var status: MutableList? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(jobDataPointListParams: JobDataPointListParams) = apply { - jobType = jobDataPointListParams.jobType - createdAtOnOrAfter = jobDataPointListParams.createdAtOnOrAfter - createdAtOnOrBefore = jobDataPointListParams.createdAtOnOrBefore - hours = jobDataPointListParams.hours - organizationId = jobDataPointListParams.organizationId - pageSize = jobDataPointListParams.pageSize - pageToken = jobDataPointListParams.pageToken - projectId = jobDataPointListParams.projectId - status = jobDataPointListParams.status?.toMutableList() - additionalHeaders = jobDataPointListParams.additionalHeaders.toBuilder() - additionalQueryParams = jobDataPointListParams.additionalQueryParams.toBuilder() - } - - /** Job type to query. */ - fun jobType(jobType: JobType) = apply { this.jobType = jobType } - - /** Include items created at or after this timestamp (inclusive) */ - fun createdAtOnOrAfter(createdAtOnOrAfter: OffsetDateTime?) = apply { - this.createdAtOnOrAfter = createdAtOnOrAfter - } - - /** - * Alias for calling [Builder.createdAtOnOrAfter] with `createdAtOnOrAfter.orElse(null)`. - */ - fun createdAtOnOrAfter(createdAtOnOrAfter: Optional) = - createdAtOnOrAfter(createdAtOnOrAfter.getOrNull()) - - /** Include items created at or before this timestamp (inclusive) */ - fun createdAtOnOrBefore(createdAtOnOrBefore: OffsetDateTime?) = apply { - this.createdAtOnOrBefore = createdAtOnOrBefore - } - - /** - * Alias for calling [Builder.createdAtOnOrBefore] with `createdAtOnOrBefore.orElse(null)`. - */ - fun createdAtOnOrBefore(createdAtOnOrBefore: Optional) = - createdAtOnOrBefore(createdAtOnOrBefore.getOrNull()) - - /** Hours of history to include. */ - fun hours(hours: Long?) = apply { this.hours = hours } - - /** - * Alias for [Builder.hours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hours(hours: Long) = hours(hours as Long?) - - /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ - fun hours(hours: Optional) = hours(hours.getOrNull()) - - fun organizationId(organizationId: String?) = apply { this.organizationId = organizationId } - - /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ - fun organizationId(organizationId: Optional) = - organizationId(organizationId.getOrNull()) - - /** Number of items per page. */ - fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } - - /** - * Alias for [Builder.pageSize]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) - - /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ - fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) - - /** Cursor token for the next page. */ - fun pageToken(pageToken: String?) = apply { this.pageToken = pageToken } - - /** Alias for calling [Builder.pageToken] with `pageToken.orElse(null)`. */ - fun pageToken(pageToken: Optional) = pageToken(pageToken.getOrNull()) - - fun projectId(projectId: String?) = apply { this.projectId = projectId } - - /** Alias for calling [Builder.projectId] with `projectId.orElse(null)`. */ - fun projectId(projectId: Optional) = projectId(projectId.getOrNull()) - - /** Filter by status. */ - fun status(status: List?) = apply { this.status = status?.toMutableList() } - - /** Alias for calling [Builder.status] with `status.orElse(null)`. */ - fun status(status: Optional>) = status(status.getOrNull()) - - /** - * Adds a single [String] to [Builder.status]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStatus(status: String) = apply { - this.status = (this.status ?: mutableListOf()).apply { add(status) } - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [JobDataPointListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .jobType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): JobDataPointListParams = - JobDataPointListParams( - checkRequired("jobType", jobType), - createdAtOnOrAfter, - createdAtOnOrBefore, - hours, - organizationId, - pageSize, - pageToken, - projectId, - status?.toImmutable(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - put("job_type", jobType.toString()) - createdAtOnOrAfter?.let { - put("created_at_on_or_after", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) - } - createdAtOnOrBefore?.let { - put( - "created_at_on_or_before", - DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), - ) - } - hours?.let { put("hours", it.toString()) } - organizationId?.let { put("organization_id", it) } - pageSize?.let { put("page_size", it.toString()) } - pageToken?.let { put("page_token", it) } - projectId?.let { put("project_id", it) } - status?.forEach { put("status", it) } - putAll(additionalQueryParams) - } - .build() - - /** Job type to query. */ - class JobType @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 CLASSIFY = of("classify") - - @JvmField val EXTRACT = of("extract") - - @JvmField val PARSE = of("parse") - - @JvmStatic fun of(value: String) = JobType(JsonField.of(value)) - } - - /** An enum containing [JobType]'s known values. */ - enum class Known { - CLASSIFY, - EXTRACT, - PARSE, - } - - /** - * An enum containing [JobType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [JobType] 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 { - CLASSIFY, - EXTRACT, - PARSE, - /** An enum member indicating that [JobType] 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) { - CLASSIFY -> Value.CLASSIFY - EXTRACT -> Value.EXTRACT - PARSE -> Value.PARSE - 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 LlamaCloudInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CLASSIFY -> Known.CLASSIFY - EXTRACT -> Known.EXTRACT - PARSE -> Known.PARSE - else -> throw LlamaCloudInvalidDataException("Unknown JobType: $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 LlamaCloudInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LlamaCloudInvalidDataException("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 LlamaCloudInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): JobType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LlamaCloudInvalidDataException) { - 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 JobType && 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 JobDataPointListParams && - jobType == other.jobType && - createdAtOnOrAfter == other.createdAtOnOrAfter && - createdAtOnOrBefore == other.createdAtOnOrBefore && - hours == other.hours && - organizationId == other.organizationId && - pageSize == other.pageSize && - pageToken == other.pageToken && - projectId == other.projectId && - status == other.status && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - jobType, - createdAtOnOrAfter, - createdAtOnOrBefore, - hours, - organizationId, - pageSize, - pageToken, - projectId, - status, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "JobDataPointListParams{jobType=$jobType, createdAtOnOrAfter=$createdAtOnOrAfter, createdAtOnOrBefore=$createdAtOnOrBefore, hours=$hours, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, projectId=$projectId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/Form.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/Form.kt index a55f00d..829db40 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/Form.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/Form.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.models.parsing import ai.llamaindex.llamacloud.core.BaseDeserializer import ai.llamaindex.llamacloud.core.BaseSerializer +import ai.llamaindex.llamacloud.core.Enum import ai.llamaindex.llamacloud.core.ExcludeMissing import ai.llamaindex.llamacloud.core.JsonField import ai.llamaindex.llamacloud.core.JsonMissing @@ -184,6 +185,21 @@ private constructor( fun addTableJson(rows: List>) = addJson(FormTable.builder().type(FormTable.Type.TABLE).rows(rows).build()) + /** Alias for calling [addJson] with `Json.ofText(text)`. */ + fun addJson(text: Json.Text) = addJson(Json.ofText(text)) + + /** + * Alias for calling [addJson] with the following: + * ```java + * Json.Text.builder() + * .type(Form.Json.Text.Type.TEXT) + * .value(value) + * .build() + * ``` + */ + fun addTextJson(value: String) = + addJson(Json.Text.builder().type(Form.Json.Text.Type.TEXT).value(value).build()) + /** Flattened list representation of the same content */ fun list(list: FormListItem) = list(JsonField.of(list)) @@ -282,6 +298,7 @@ private constructor( private val field: FormField? = null, private val section: FormSection? = null, private val table: FormTable? = null, + private val text: Text? = null, private val _json: JsonValue? = null, ) { @@ -294,12 +311,20 @@ private constructor( /** A fillable grid printed on the form: repeating records or a row-by-column matrix. */ fun table(): Optional = Optional.ofNullable(table) + /** + * Printed text that is not part of a field, section heading or table: a title, an + * instruction, a note. With it the form JSON holds every printed word of its region. + */ + fun text(): Optional = Optional.ofNullable(text) + fun isField(): Boolean = field != null fun isSection(): Boolean = section != null fun isTable(): Boolean = table != null + fun isText(): Boolean = text != null + /** One labeled form entry: a text input, checkbox, select group, or signature line. */ fun asField(): FormField = field.getOrThrow("field") @@ -309,6 +334,12 @@ private constructor( /** A fillable grid printed on the form: repeating records or a row-by-column matrix. */ fun asTable(): FormTable = table.getOrThrow("table") + /** + * Printed text that is not part of a field, section heading or table: a title, an + * instruction, a note. With it the form JSON holds every printed word of its region. + */ + fun asText(): Text = text.getOrThrow("text") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -345,6 +376,7 @@ private constructor( field != null -> visitor.visitField(field) section != null -> visitor.visitSection(section) table != null -> visitor.visitTable(table) + text != null -> visitor.visitText(text) else -> visitor.unknown(_json) } @@ -377,6 +409,10 @@ private constructor( override fun visitTable(table: FormTable) { table.validate() } + + override fun visitText(text: Text) { + text.validate() + } } ) validated = true @@ -406,6 +442,8 @@ private constructor( override fun visitTable(table: FormTable) = table.validity() + override fun visitText(text: Text) = text.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -418,16 +456,18 @@ private constructor( return other is Json && field == other.field && section == other.section && - table == other.table + table == other.table && + text == other.text } - override fun hashCode(): Int = Objects.hash(field, section, table) + override fun hashCode(): Int = Objects.hash(field, section, table, text) override fun toString(): String = when { field != null -> "Json{field=$field}" section != null -> "Json{section=$section}" table != null -> "Json{table=$table}" + text != null -> "Json{text=$text}" _json != null -> "Json{_unknown=$_json}" else -> throw IllegalStateException("Invalid Json") } @@ -442,6 +482,12 @@ private constructor( /** A fillable grid printed on the form: repeating records or a row-by-column matrix. */ @JvmStatic fun ofTable(table: FormTable) = Json(table = table) + + /** + * Printed text that is not part of a field, section heading or table: a title, an + * instruction, a note. With it the form JSON holds every printed word of its region. + */ + @JvmStatic fun ofText(text: Text) = Json(text = text) } /** An interface that defines how to map each variant of [Json] to a value of type [T]. */ @@ -456,6 +502,12 @@ private constructor( /** A fillable grid printed on the form: repeating records or a row-by-column matrix. */ fun visitTable(table: FormTable): T + /** + * Printed text that is not part of a field, section heading or table: a title, an + * instruction, a note. With it the form JSON holds every printed word of its region. + */ + fun visitText(text: Text): T + /** * Maps an unknown variant of [Json] to a value of type [T]. * @@ -492,6 +544,11 @@ private constructor( Json(table = it, _json = json) } ?: Json(_json = json) } + "text" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + Json(text = it, _json = json) + } ?: Json(_json = json) + } } return Json(_json = json) @@ -509,11 +566,2978 @@ private constructor( value.field != null -> generator.writeObject(value.field) value.section != null -> generator.writeObject(value.section) value.table != null -> generator.writeObject(value.table) + value.text != null -> generator.writeObject(value.text) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Json") } } } + + /** + * Printed text that is not part of a field, section heading or table: a title, an + * instruction, a note. With it the form JSON holds every printed word of its region. + */ + class Text + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val value: JsonField, + private val bbox: JsonField>, + private val grounding: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + @JsonProperty("bbox") + @ExcludeMissing + bbox: JsonField> = JsonMissing.of(), + @JsonProperty("grounding") + @ExcludeMissing + grounding: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(value, bbox, grounding, type, mutableMapOf()) + + /** + * The printed text, verbatim + * + * @throws LlamaCloudInvalidDataException 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") + + /** + * Bounding boxes of the text on the page, if attributed. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun bbox(): Optional> = bbox.getOptional("bbox") + + /** + * Optional grounding for a field's printed text; boolean states have no text spans. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun grounding(): Optional = grounding.getOptional("grounding") + + /** + * Form text node + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * 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 + + /** + * Returns the raw JSON value of [bbox]. + * + * Unlike [bbox], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bbox") @ExcludeMissing fun _bbox(): JsonField> = bbox + + /** + * Returns the raw JSON value of [grounding]. + * + * Unlike [grounding], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("grounding") + @ExcludeMissing + fun _grounding(): JsonField = grounding + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @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 [Text]. + * + * The following fields are required: + * ```java + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Text]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var bbox: JsonField>? = null + private var grounding: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(text: Text) = apply { + value = text.value + bbox = text.bbox.map { it.toMutableList() } + grounding = text.grounding + type = text.type + additionalProperties = text.additionalProperties.toMutableMap() + } + + /** The printed text, verbatim */ + 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 } + + /** Bounding boxes of the text on the page, if attributed. */ + fun bbox(bbox: List?) = bbox(JsonField.ofNullable(bbox)) + + /** Alias for calling [Builder.bbox] with `bbox.orElse(null)`. */ + fun bbox(bbox: Optional>) = bbox(bbox.getOrNull()) + + /** + * Sets [Builder.bbox] to an arbitrary JSON value. + * + * You should usually call [Builder.bbox] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun bbox(bbox: JsonField>) = apply { + this.bbox = bbox.map { it.toMutableList() } + } + + /** + * Adds a single [BBox] to [Builder.bbox]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBbox(bbox: BBox) = apply { + this.bbox = + (this.bbox ?: JsonField.of(mutableListOf())).also { + checkKnown("bbox", it).add(bbox) + } + } + + /** + * Optional grounding for a field's printed text; boolean states have no text spans. + */ + fun grounding(grounding: Grounding?) = grounding(JsonField.ofNullable(grounding)) + + /** Alias for calling [Builder.grounding] with `grounding.orElse(null)`. */ + fun grounding(grounding: Optional) = grounding(grounding.getOrNull()) + + /** + * Sets [Builder.grounding] to an arbitrary JSON value. + * + * You should usually call [Builder.grounding] with a well-typed [Grounding] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun grounding(grounding: JsonField) = apply { + this.grounding = grounding + } + + /** Form text node */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + 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 [Text]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Text = + Text( + checkRequired("value", value), + (bbox ?: JsonMissing.of()).map { it.toImmutable() }, + grounding, + type, + 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 LlamaCloudInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Text = apply { + if (validated) { + return@apply + } + + value() + bbox().ifPresent { it.forEach { it.validate() } } + grounding().ifPresent { it.validate() } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LlamaCloudInvalidDataException) { + 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.asKnown().isPresent) 1 else 0) + + (bbox.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (grounding.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Optional grounding for a field's printed text; boolean states have no text spans. */ + class Grounding + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val label: JsonField